<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The AQUA Project, Glasgow University, 1998


Desugaring foreign declarations (see also GHC.HsToCore.Foreign.Call).
-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-10"></span><span class="hs-pragma">{-# LANGUAGE FlexibleContexts #-}</span><span>
</span><span id="line-11"></span><span class="hs-pragma">{-# LANGUAGE TypeFamilies #-}</span><span>
</span><span id="line-12"></span><span class="hs-pragma">{-# LANGUAGE ViewPatterns #-}</span><span>
</span><span id="line-13"></span><span>
</span><span id="line-14"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}</span><span>
</span><span id="line-15"></span><span>
</span><span id="line-16"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.HsToCore.Foreign.Decl</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsForeigns"><span class="hs-identifier">dsForeigns</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span>        </span><span class="hs-comment">-- temp</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html"><span class="hs-identifier">GHC.HsToCore.Foreign.Call</span></a></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.HsToCore.Monad.html"><span class="hs-identifier">GHC.HsToCore.Monad</span></a></span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Hs.html"><span class="hs-identifier">GHC.Hs</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Unfold.html"><span class="hs-identifier">GHC.Core.Unfold</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Literal.html"><span class="hs-identifier">GHC.Types.Literal</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Unit.Module.html"><span class="hs-identifier">GHC.Unit.Module</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.RepType.html"><span class="hs-identifier">GHC.Types.RepType</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html"><span class="hs-identifier">GHC.Tc.Utils.Env</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html"><span class="hs-identifier">GHC.Cmm.Expr</span></a></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Utils.html"><span class="hs-identifier">GHC.Cmm.Utils</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html"><span class="hs-identifier">GHC.Driver.Types</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html"><span class="hs-identifier">GHC.Types.ForeignCall</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html"><span class="hs-identifier">GHC.Builtin.Types</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.Prim.html"><span class="hs-identifier">GHC.Builtin.Types.Prim</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html"><span class="hs-identifier">GHC.Types.SrcLoc</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.OrdList.html"><span class="hs-identifier">GHC.Data.OrdList</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Hooks.html"><span class="hs-identifier">GHC.Driver.Hooks</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Encoding.html"><span class="hs-identifier">GHC.Utils.Encoding</span></a></span><span>
</span><span id="line-60"></span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>
</span><span id="line-63"></span><span>
</span><span id="line-64"></span><span class="hs-comment">{-
Desugaring of @foreign@ declarations is naturally split up into
parts, an @import@ and an @export@  part. A @foreign import@
declaration
\begin{verbatim}
  foreign import cc nm f :: prim_args -&gt; IO prim_res
\end{verbatim}
is the same as
\begin{verbatim}
  f :: prim_args -&gt; IO prim_res
  f a1 ... an = _ccall_ nm cc a1 ... an
\end{verbatim}
so we reuse the desugaring code in @GHC.HsToCore.Foreign.Call@ to deal with these.
-}</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="hs-keyword">type</span><span> </span><span id="Binding"><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#Binding"><span class="hs-identifier hs-var">Binding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- No rec/nonrec structure;</span><span>
</span><span id="line-80"></span><span>                              </span><span class="hs-comment">-- the occurrence analyser will sort it all out</span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsForeigns"><span class="hs-identifier hs-type">dsForeigns</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-83"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Types.html#ForeignStubs"><span class="hs-identifier hs-type">ForeignStubs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.OrdList.html#OrdList"><span class="hs-identifier hs-type">OrdList</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#Binding"><span class="hs-identifier hs-type">Binding</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-84"></span><span id="dsForeigns"><span class="annot"><span class="annottext">dsForeigns :: [LForeignDecl GhcTc] -&gt; DsM (ForeignStubs, OrdList Binding)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsForeigns"><span class="hs-identifier hs-var hs-var">dsForeigns</span></a></span></span><span> </span><span id="local-6989586621681188166"><span class="annot"><span class="annottext">[LForeignDecl GhcTc]
</span><a href="#local-6989586621681188166"><span class="hs-identifier hs-var">fos</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Hooks
 -&gt; Maybe
      ([LForeignDecl GhcTc] -&gt; DsM (ForeignStubs, OrdList Binding)))
-&gt; ([LForeignDecl GhcTc] -&gt; DsM (ForeignStubs, OrdList Binding))
-&gt; IOEnv
     (Env DsGblEnv DsLclEnv)
     ([LForeignDecl GhcTc] -&gt; DsM (ForeignStubs, OrdList Binding))
forall (f :: * -&gt; *) a.
(Functor f, HasDynFlags f) =&gt;
(Hooks -&gt; Maybe a) -&gt; a -&gt; f a
</span><a href="GHC.Driver.Hooks.html#getHooked"><span class="hs-identifier hs-var">getHooked</span></a></span><span> </span><span class="annot"><span class="annottext">Hooks
-&gt; Maybe
     ([LForeignDecl GhcTc] -&gt; DsM (ForeignStubs, OrdList Binding))
</span><a href="GHC.Driver.Hooks.html#dsForeignsHook"><span class="hs-identifier hs-var hs-var">dsForeignsHook</span></a></span><span> </span><span class="annot"><span class="annottext">[LForeignDecl GhcTc] -&gt; DsM (ForeignStubs, OrdList Binding)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsForeigns%27"><span class="hs-identifier hs-var">dsForeigns'</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv
  (Env DsGblEnv DsLclEnv)
  ([LForeignDecl GhcTc] -&gt; DsM (ForeignStubs, OrdList Binding))
-&gt; (([LForeignDecl GhcTc] -&gt; DsM (ForeignStubs, OrdList Binding))
    -&gt; DsM (ForeignStubs, OrdList Binding))
-&gt; DsM (ForeignStubs, OrdList Binding)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">([LForeignDecl GhcTc] -&gt; DsM (ForeignStubs, OrdList Binding))
-&gt; [LForeignDecl GhcTc] -&gt; DsM (ForeignStubs, OrdList Binding)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[LForeignDecl GhcTc]
</span><a href="#local-6989586621681188166"><span class="hs-identifier hs-var">fos</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsForeigns%27"><span class="hs-identifier hs-type">dsForeigns'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-87"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Types.html#ForeignStubs"><span class="hs-identifier hs-type">ForeignStubs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.OrdList.html#OrdList"><span class="hs-identifier hs-type">OrdList</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#Binding"><span class="hs-identifier hs-type">Binding</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-88"></span><span id="dsForeigns%27"><span class="annot"><span class="annottext">dsForeigns' :: [LForeignDecl GhcTc] -&gt; DsM (ForeignStubs, OrdList Binding)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsForeigns%27"><span class="hs-identifier hs-var hs-var">dsForeigns'</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-89"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ForeignStubs, OrdList Binding)
-&gt; DsM (ForeignStubs, OrdList Binding)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignStubs
</span><a href="GHC.Driver.Types.html#NoStubs"><span class="hs-identifier hs-var">NoStubs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">OrdList Binding
forall a. OrdList a
</span><a href="GHC.Data.OrdList.html#nilOL"><span class="hs-identifier hs-var">nilOL</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-90"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsForeigns%27"><span class="hs-identifier hs-var">dsForeigns'</span></a></span><span> </span><span id="local-6989586621681188160"><span class="annot"><span class="annottext">[LForeignDecl GhcTc]
</span><a href="#local-6989586621681188160"><span class="hs-identifier hs-var">fos</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-91"></span><span>    </span><span id="local-6989586621681188159"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681188159"><span class="hs-identifier hs-var">mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-92"></span><span>    </span><span id="local-6989586621681188157"><span class="annot"><span class="annottext">[(SDoc, SDoc, [Id], [Binding])]
</span><a href="#local-6989586621681188157"><span class="hs-identifier hs-var">fives</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(LForeignDecl GhcTc
 -&gt; IOEnv (Env DsGblEnv DsLclEnv) (SDoc, SDoc, [Id], [Binding]))
-&gt; [LForeignDecl GhcTc]
-&gt; IOEnv (Env DsGblEnv DsLclEnv) [(SDoc, SDoc, [Id], [Binding])]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">LForeignDecl GhcTc
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (SDoc, SDoc, [Id], [Binding])
</span><a href="#local-6989586621681188155"><span class="hs-identifier hs-var">do_ldecl</span></a></span><span> </span><span class="annot"><span class="annottext">[LForeignDecl GhcTc]
</span><a href="#local-6989586621681188160"><span class="hs-identifier hs-var">fos</span></a></span><span>
</span><span id="line-93"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-94"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681188154"><span class="annot"><span class="annottext">[SDoc]
</span><a href="#local-6989586621681188154"><span class="hs-identifier hs-var">hs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188153"><span class="annot"><span class="annottext">[SDoc]
</span><a href="#local-6989586621681188153"><span class="hs-identifier hs-var">cs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188152"><span class="annot"><span class="annottext">[[Id]]
</span><a href="#local-6989586621681188152"><span class="hs-identifier hs-var">idss</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188151"><span class="annot"><span class="annottext">[[Binding]]
</span><a href="#local-6989586621681188151"><span class="hs-identifier hs-var">bindss</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, [Id], [Binding])]
-&gt; ([SDoc], [SDoc], [[Id]], [[Binding]])
forall a b c d. [(a, b, c, d)] -&gt; ([a], [b], [c], [d])
</span><a href="../../base/src/Data.OldList.html#unzip4"><span class="hs-identifier hs-var">unzip4</span></a></span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, [Id], [Binding])]
</span><a href="#local-6989586621681188157"><span class="hs-identifier hs-var">fives</span></a></span><span>
</span><span id="line-95"></span><span>        </span><span id="local-6989586621681188149"><span class="annot"><span class="annottext">fe_ids :: [Id]
</span><a href="#local-6989586621681188149"><span class="hs-identifier hs-var hs-var">fe_ids</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[[Id]] -&gt; [Id]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="annot"><span class="annottext">[[Id]]
</span><a href="#local-6989586621681188152"><span class="hs-identifier hs-var">idss</span></a></span><span>
</span><span id="line-96"></span><span>        </span><span id="local-6989586621681188147"><span class="annot"><span class="annottext">fe_init_code :: SDoc
</span><a href="#local-6989586621681188147"><span class="hs-identifier hs-var hs-var">fe_init_code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Module -&gt; [Id] -&gt; SDoc
</span><a href="GHC.HsToCore.Foreign.Decl.html#foreignExportsInitialiser"><span class="hs-identifier hs-var">foreignExportsInitialiser</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681188159"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681188149"><span class="hs-identifier hs-var">fe_ids</span></a></span><span>
</span><span id="line-97"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-98"></span><span>    </span><span class="annot"><span class="annottext">(ForeignStubs, OrdList Binding)
-&gt; DsM (ForeignStubs, OrdList Binding)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; ForeignStubs
</span><a href="GHC.Driver.Types.html#ForeignStubs"><span class="hs-identifier hs-var">ForeignStubs</span></a></span><span>
</span><span id="line-99"></span><span>             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc]
</span><a href="#local-6989586621681188154"><span class="hs-identifier hs-var">hs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-100"></span><span>             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc]
</span><a href="#local-6989586621681188153"><span class="hs-identifier hs-var">cs</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681188147"><span class="hs-identifier hs-var">fe_init_code</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-101"></span><span>            </span><span class="annot"><span class="annottext">([Binding] -&gt; OrdList Binding -&gt; OrdList Binding)
-&gt; OrdList Binding -&gt; [[Binding]] -&gt; OrdList Binding
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OrdList Binding -&gt; OrdList Binding -&gt; OrdList Binding
forall a. OrdList a -&gt; OrdList a -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#appOL"><span class="hs-identifier hs-var">appOL</span></a></span><span> </span><span class="annot"><span class="annottext">(OrdList Binding -&gt; OrdList Binding -&gt; OrdList Binding)
-&gt; ([Binding] -&gt; OrdList Binding)
-&gt; [Binding]
-&gt; OrdList Binding
-&gt; OrdList Binding
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">[Binding] -&gt; OrdList Binding
forall a. [a] -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#toOL"><span class="hs-identifier hs-var">toOL</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OrdList Binding
forall a. OrdList a
</span><a href="GHC.Data.OrdList.html#nilOL"><span class="hs-identifier hs-var">nilOL</span></a></span><span> </span><span class="annot"><span class="annottext">[[Binding]]
</span><a href="#local-6989586621681188151"><span class="hs-identifier hs-var">bindss</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-103"></span><span>   </span><span id="local-6989586621681188155"><span class="annot"><span class="annottext">do_ldecl :: LForeignDecl GhcTc
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (SDoc, SDoc, [Id], [Binding])
</span><a href="#local-6989586621681188155"><span class="hs-identifier hs-var hs-var">do_ldecl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681188137"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681188137"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681188136"><span class="annot"><span class="annottext">ForeignDecl GhcTc
</span><a href="#local-6989586621681188136"><span class="hs-identifier hs-var">decl</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (SDoc, SDoc, [Id], [Binding])
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (SDoc, SDoc, [Id], [Binding])
forall a. SrcSpan -&gt; DsM a -&gt; DsM a
</span><a href="GHC.HsToCore.Monad.html#putSrcSpanDs"><span class="hs-identifier hs-var">putSrcSpanDs</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681188137"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignDecl GhcTc
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (SDoc, SDoc, [Id], [Binding])
</span><a href="#local-6989586621681188134"><span class="hs-identifier hs-var">do_decl</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignDecl GhcTc
</span><a href="#local-6989586621681188136"><span class="hs-identifier hs-var">decl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span>
</span><span id="line-105"></span><span>   </span><span class="annot"><a href="#local-6989586621681188134"><span class="hs-identifier hs-type">do_decl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignDecl"><span class="hs-identifier hs-type">ForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#Binding"><span class="hs-identifier hs-type">Binding</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-106"></span><span>   </span><span id="local-6989586621681188134"><span class="annot"><span class="annottext">do_decl :: ForeignDecl GhcTc
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (SDoc, SDoc, [Id], [Binding])
</span><a href="#local-6989586621681188134"><span class="hs-identifier hs-var hs-var">do_decl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignImport"><span class="hs-identifier hs-type">ForeignImport</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">fd_name :: forall pass. ForeignDecl pass -&gt; Located (IdP pass)
</span><a href="GHC.Hs.Decls.html#fd_name"><span class="hs-identifier hs-var">fd_name</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681188131"><span class="annot"><span class="annottext">Located (IdP GhcTc)
</span><a href="#local-6989586621681188131"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_i_ext :: forall pass. ForeignDecl pass -&gt; XForeignImport pass
</span><a href="GHC.Hs.Decls.html#fd_i_ext"><span class="hs-identifier hs-var">fd_i_ext</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681188129"><span class="annot"><span class="annottext">XForeignImport GhcTc
</span><a href="#local-6989586621681188129"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_fi :: forall pass. ForeignDecl pass -&gt; ForeignImport
</span><a href="GHC.Hs.Decls.html#fd_fi"><span class="hs-identifier hs-var">fd_fi</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681188127"><span class="annot"><span class="annottext">ForeignImport
</span><a href="#local-6989586621681188127"><span class="hs-identifier hs-var">spec</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-107"></span><span>      </span><span class="annot"><span class="annottext">SDoc -&gt; TcRnIf DsGblEnv DsLclEnv ()
forall m n. SDoc -&gt; TcRnIf m n ()
</span><a href="GHC.Tc.Utils.Monad.html#traceIf"><span class="hs-identifier hs-var">traceIf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;fi start&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Located Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Located Id
Located (IdP GhcTc)
</span><a href="#local-6989586621681188131"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-108"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681188122"><span class="annot"><span class="annottext">id' :: Id
</span><a href="#local-6989586621681188122"><span class="hs-identifier hs-var hs-var">id'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Located Id -&gt; Id
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">Located Id
Located (IdP GhcTc)
</span><a href="#local-6989586621681188131"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-109"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681188120"><span class="annot"><span class="annottext">[Binding]
</span><a href="#local-6989586621681188120"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188119"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681188119"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188118"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681188118"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Coercion -&gt; ForeignImport -&gt; DsM ([Binding], SDoc, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsFImport"><span class="hs-identifier hs-var">dsFImport</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188122"><span class="hs-identifier hs-var">id'</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
XForeignImport GhcTc
</span><a href="#local-6989586621681188129"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignImport
</span><a href="#local-6989586621681188127"><span class="hs-identifier hs-var">spec</span></a></span><span>
</span><span id="line-110"></span><span>      </span><span class="annot"><span class="annottext">SDoc -&gt; TcRnIf DsGblEnv DsLclEnv ()
forall m n. SDoc -&gt; TcRnIf m n ()
</span><a href="GHC.Tc.Utils.Monad.html#traceIf"><span class="hs-identifier hs-var">traceIf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;fi end&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Located Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Located Id
Located (IdP GhcTc)
</span><a href="#local-6989586621681188131"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-111"></span><span>      </span><span class="annot"><span class="annottext">(SDoc, SDoc, [Id], [Binding])
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (SDoc, SDoc, [Id], [Binding])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681188119"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681188118"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Binding]
</span><a href="#local-6989586621681188120"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-112"></span><span>
</span><span id="line-113"></span><span>   </span><span class="annot"><a href="#local-6989586621681188134"><span class="hs-identifier hs-var">do_decl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignExport"><span class="hs-identifier hs-type">ForeignExport</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">fd_name :: forall pass. ForeignDecl pass -&gt; Located (IdP pass)
</span><a href="GHC.Hs.Decls.html#fd_name"><span class="hs-identifier hs-var">fd_name</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681188115"><span class="annot"><span class="annottext">IdP GhcTc
</span><a href="#local-6989586621681188115"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-114"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_e_ext :: forall pass. ForeignDecl pass -&gt; XForeignExport pass
</span><a href="GHC.Hs.Decls.html#fd_e_ext"><span class="hs-identifier hs-var">fd_e_ext</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681188113"><span class="annot"><span class="annottext">XForeignExport GhcTc
</span><a href="#local-6989586621681188113"><span class="hs-identifier hs-var">co</span></a></span></span><span>
</span><span id="line-115"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_fe :: forall pass. ForeignDecl pass -&gt; ForeignExport
</span><a href="GHC.Hs.Decls.html#fd_fe"><span class="hs-identifier hs-var">fd_fe</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#CExport"><span class="hs-identifier hs-type">CExport</span></a></span><span>
</span><span id="line-116"></span><span>                              </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.ForeignCall.html#CExportStatic"><span class="hs-identifier hs-type">CExportStatic</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681188109"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681188109"><span class="hs-identifier hs-var">ext_nm</span></a></span></span><span> </span><span id="local-6989586621681188108"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681188108"><span class="hs-identifier hs-var">cconv</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Located SourceText
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-117"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681188107"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681188107"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188106"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681188106"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; Coercion
-&gt; CLabelString
-&gt; CCallConv
-&gt; Bool
-&gt; DsM (SDoc, SDoc, String, Arity)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsFExport"><span class="hs-identifier hs-var">dsFExport</span></a></span><span> </span><span class="annot"><span class="annottext">Id
IdP GhcTc
</span><a href="#local-6989586621681188115"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
XForeignExport GhcTc
</span><a href="#local-6989586621681188113"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681188109"><span class="hs-identifier hs-var">ext_nm</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681188108"><span class="hs-identifier hs-var">cconv</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-118"></span><span>      </span><span class="annot"><span class="annottext">(SDoc, SDoc, [Id], [Binding])
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (SDoc, SDoc, [Id], [Binding])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681188107"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681188106"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
IdP GhcTc
</span><a href="#local-6989586621681188115"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Foreign import}
*                                                                      *
************************************************************************

Desugaring foreign imports is just the matter of creating a binding
that on its RHS unboxes its arguments, performs the external call
(using the @CCallOp@ primop), before boxing the result up and returning it.

However, we create a worker/wrapper pair, thus:

        foreign import f :: Int -&gt; IO Int
==&gt;
        f x = IO ( \s -&gt; case x of { I# x# -&gt;
                         case fw s x# of { (# s1, y# #) -&gt;
                         (# s1, I# y# #)}})

        fw s x# = ccall f s x#

The strictness/CPR analyser won't do this automatically because it doesn't look
inside returned tuples; but inlining this wrapper is a Really Good Idea
because it exposes the boxing to the call site.
-}</span><span>
</span><span id="line-145"></span><span>
</span><span id="line-146"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsFImport"><span class="hs-identifier hs-type">dsFImport</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-147"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-148"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignImport"><span class="hs-identifier hs-type">ForeignImport</span></a></span><span>
</span><span id="line-149"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#Binding"><span class="hs-identifier hs-type">Binding</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-150"></span><span id="dsFImport"><span class="annot"><span class="annottext">dsFImport :: Id -&gt; Coercion -&gt; ForeignImport -&gt; DsM ([Binding], SDoc, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsFImport"><span class="hs-identifier hs-var hs-var">dsFImport</span></a></span></span><span> </span><span id="local-6989586621681188104"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188104"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621681188103"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188103"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#CImport"><span class="hs-identifier hs-type">CImport</span></a></span><span> </span><span id="local-6989586621681188101"><span class="annot"><span class="annottext">Located CCallConv
</span><a href="#local-6989586621681188101"><span class="hs-identifier hs-var">cconv</span></a></span></span><span> </span><span id="local-6989586621681188100"><span class="annot"><span class="annottext">Located Safety
</span><a href="#local-6989586621681188100"><span class="hs-identifier hs-var">safety</span></a></span></span><span> </span><span id="local-6989586621681188099"><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681188099"><span class="hs-identifier hs-var">mHeader</span></a></span></span><span> </span><span id="local-6989586621681188098"><span class="annot"><span class="annottext">CImportSpec
</span><a href="#local-6989586621681188098"><span class="hs-identifier hs-var">spec</span></a></span></span><span> </span><span class="annot"><span class="annottext">Located SourceText
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-151"></span><span>    </span><span class="annot"><span class="annottext">Id
-&gt; Coercion
-&gt; CImportSpec
-&gt; CCallConv
-&gt; Safety
-&gt; Maybe Header
-&gt; DsM ([Binding], SDoc, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsCImport"><span class="hs-identifier hs-var">dsCImport</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188104"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188103"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">CImportSpec
</span><a href="#local-6989586621681188098"><span class="hs-identifier hs-var">spec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Located CCallConv -&gt; CCallConv
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">Located CCallConv
</span><a href="#local-6989586621681188101"><span class="hs-identifier hs-var">cconv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Located Safety -&gt; Safety
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">Located Safety
</span><a href="#local-6989586621681188100"><span class="hs-identifier hs-var">safety</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681188099"><span class="hs-identifier hs-var">mHeader</span></a></span><span>
</span><span id="line-152"></span><span>
</span><span id="line-153"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsCImport"><span class="hs-identifier hs-type">dsCImport</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-154"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-155"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#CImportSpec"><span class="hs-identifier hs-type">CImportSpec</span></a></span><span>
</span><span id="line-156"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-type">CCallConv</span></a></span><span>
</span><span id="line-157"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#Safety"><span class="hs-identifier hs-type">Safety</span></a></span><span>
</span><span id="line-158"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#Header"><span class="hs-identifier hs-type">Header</span></a></span><span>
</span><span id="line-159"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#Binding"><span class="hs-identifier hs-type">Binding</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-160"></span><span id="dsCImport"><span class="annot"><span class="annottext">dsCImport :: Id
-&gt; Coercion
-&gt; CImportSpec
-&gt; CCallConv
-&gt; Safety
-&gt; Maybe Header
-&gt; DsM ([Binding], SDoc, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsCImport"><span class="hs-identifier hs-var hs-var">dsCImport</span></a></span></span><span> </span><span id="local-6989586621681188096"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188096"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621681188095"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188095"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#CLabel"><span class="hs-identifier hs-type">CLabel</span></a></span><span> </span><span id="local-6989586621681188093"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681188093"><span class="hs-identifier hs-var">cid</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681188092"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681188092"><span class="hs-identifier hs-var">cconv</span></a></span></span><span> </span><span class="annot"><span class="annottext">Safety
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe Header
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-161"></span><span>   </span><span id="local-6989586621681188091"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681188091"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-162"></span><span>   </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681188089"><span class="annot"><span class="annottext">ty :: Type
</span><a href="#local-6989586621681188089"><span class="hs-identifier hs-var hs-var">ty</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type
</span><a href="GHC.Core.Coercion.html#coercionLKind"><span class="hs-identifier hs-var">coercionLKind</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188095"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-163"></span><span>       </span><span id="local-6989586621681188087"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681188087"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681188091"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-164"></span><span>       </span><span id="local-6989586621681188085"><span class="annot"><span class="annottext">fod :: FunctionOrData
</span><a href="#local-6989586621681188085"><span class="hs-identifier hs-var hs-var">fod</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe TyCon
</span><a href="GHC.Core.Type.html#tyConAppTyCon_maybe"><span class="hs-identifier hs-var">tyConAppTyCon_maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="GHC.Core.Type.html#dropForAlls"><span class="hs-identifier hs-var">dropForAlls</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188089"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-165"></span><span>             </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681188082"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188082"><span class="hs-identifier hs-var">tycon</span></a></span></span><span>
</span><span id="line-166"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique
</span><a href="GHC.Core.TyCon.html#tyConUnique"><span class="hs-identifier hs-var hs-var">tyConUnique</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188082"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#funPtrTyConKey"><span class="hs-identifier hs-var">funPtrTyConKey</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-167"></span><span>                 </span><span class="annot"><span class="annottext">FunctionOrData
</span><a href="GHC.Types.Basic.html#IsFunction"><span class="hs-identifier hs-var">IsFunction</span></a></span><span>
</span><span id="line-168"></span><span>             </span><span class="annot"><span class="annottext">Maybe TyCon
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FunctionOrData
</span><a href="GHC.Types.Basic.html#IsData"><span class="hs-identifier hs-var">IsData</span></a></span><span>
</span><span id="line-169"></span><span>   </span><span class="hs-special">(</span><span id="local-6989586621681188077"><span class="annot"><span class="annottext">Maybe Type
</span><a href="#local-6989586621681188077"><span class="hs-identifier hs-var">resTy</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188076"><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188076"><span class="hs-identifier hs-var">foRhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#resultWrapper"><span class="hs-identifier hs-var">resultWrapper</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188089"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-170"></span><span>   </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">fromJust</span><span> </span><span class="hs-identifier">resTy</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">eqType</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">addrPrimTy</span><span class="hs-special">)</span><span>    </span><span class="hs-comment">-- typechecker ensures this</span><span>
</span><span id="line-171"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-172"></span><span>        </span><span id="local-6989586621681188067"><span class="annot"><span class="annottext">rhs :: CoreExpr
</span><a href="#local-6989586621681188067"><span class="hs-identifier hs-var hs-var">rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188076"><span class="hs-identifier hs-var">foRhs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Literal -&gt; CoreExpr
forall b. Literal -&gt; Expr b
</span><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-var">Lit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabelString -&gt; Maybe Arity -&gt; FunctionOrData -&gt; Literal
</span><a href="GHC.Types.Literal.html#LitLabel"><span class="hs-identifier hs-var">LitLabel</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681188093"><span class="hs-identifier hs-var">cid</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Arity
</span><a href="#local-6989586621681188064"><span class="hs-identifier hs-var">stdcall_info</span></a></span><span> </span><span class="annot"><span class="annottext">FunctionOrData
</span><a href="#local-6989586621681188085"><span class="hs-identifier hs-var">fod</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-173"></span><span>        </span><span id="local-6989586621681188063"><span class="annot"><span class="annottext">rhs' :: CoreExpr
</span><a href="#local-6989586621681188063"><span class="hs-identifier hs-var hs-var">rhs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Coercion -&gt; CoreExpr
forall b. Expr b -&gt; Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188067"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188095"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-174"></span><span>        </span><span id="local-6989586621681188064"><span class="annot"><span class="annottext">stdcall_info :: Maybe Arity
</span><a href="#local-6989586621681188064"><span class="hs-identifier hs-var hs-var">stdcall_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CCallConv -&gt; Type -&gt; Maybe Arity
</span><a href="GHC.HsToCore.Foreign.Decl.html#fun_type_arg_stdcall_info"><span class="hs-identifier hs-var">fun_type_arg_stdcall_info</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681188087"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681188092"><span class="hs-identifier hs-var">cconv</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188089"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-175"></span><span>    </span><span class="hs-keyword">in</span><span>
</span><span id="line-176"></span><span>    </span><span class="annot"><span class="annottext">([Binding], SDoc, SDoc) -&gt; DsM ([Binding], SDoc, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188096"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188063"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-177"></span><span>
</span><span id="line-178"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsCImport"><span class="hs-identifier hs-var">dsCImport</span></a></span><span> </span><span id="local-6989586621681188059"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188059"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621681188058"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188058"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#CFunction"><span class="hs-identifier hs-type">CFunction</span></a></span><span> </span><span id="local-6989586621681188056"><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681188056"><span class="hs-identifier hs-var">target</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681188055"><span class="annot"><span class="annottext">cconv :: CCallConv
</span><a href="#local-6989586621681188055"><span class="hs-identifier hs-var">cconv</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#PrimCallConv"><span class="hs-identifier hs-var">PrimCallConv</span></a></span><span> </span><span id="local-6989586621681188053"><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681188053"><span class="hs-identifier hs-var">safety</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Header
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-179"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Coercion -&gt; ForeignCall -&gt; DsM ([Binding], SDoc, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsPrimCall"><span class="hs-identifier hs-var">dsPrimCall</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188059"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188058"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CCallSpec -&gt; ForeignCall
</span><a href="GHC.Types.ForeignCall.html#CCall"><span class="hs-identifier hs-var">CCall</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CCallTarget -&gt; CCallConv -&gt; Safety -&gt; CCallSpec
</span><a href="GHC.Types.ForeignCall.html#CCallSpec"><span class="hs-identifier hs-var">CCallSpec</span></a></span><span> </span><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681188056"><span class="hs-identifier hs-var">target</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681188055"><span class="hs-identifier hs-var">cconv</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681188053"><span class="hs-identifier hs-var">safety</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-180"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsCImport"><span class="hs-identifier hs-var">dsCImport</span></a></span><span> </span><span id="local-6989586621681188049"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188049"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621681188048"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188048"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#CFunction"><span class="hs-identifier hs-type">CFunction</span></a></span><span> </span><span id="local-6989586621681188047"><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681188047"><span class="hs-identifier hs-var">target</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681188046"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681188046"><span class="hs-identifier hs-var">cconv</span></a></span></span><span> </span><span id="local-6989586621681188045"><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681188045"><span class="hs-identifier hs-var">safety</span></a></span></span><span> </span><span id="local-6989586621681188044"><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681188044"><span class="hs-identifier hs-var">mHeader</span></a></span></span><span>
</span><span id="line-181"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; Coercion
-&gt; ForeignCall
-&gt; Maybe Header
-&gt; DsM ([Binding], SDoc, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsFCall"><span class="hs-identifier hs-var">dsFCall</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188049"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188048"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CCallSpec -&gt; ForeignCall
</span><a href="GHC.Types.ForeignCall.html#CCall"><span class="hs-identifier hs-var">CCall</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CCallTarget -&gt; CCallConv -&gt; Safety -&gt; CCallSpec
</span><a href="GHC.Types.ForeignCall.html#CCallSpec"><span class="hs-identifier hs-var">CCallSpec</span></a></span><span> </span><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681188047"><span class="hs-identifier hs-var">target</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681188046"><span class="hs-identifier hs-var">cconv</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681188045"><span class="hs-identifier hs-var">safety</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681188044"><span class="hs-identifier hs-var">mHeader</span></a></span><span>
</span><span id="line-182"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsCImport"><span class="hs-identifier hs-var">dsCImport</span></a></span><span> </span><span id="local-6989586621681188042"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188042"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621681188041"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188041"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="annot"><span class="annottext">CImportSpec
</span><a href="GHC.Hs.Decls.html#CWrapper"><span class="hs-identifier hs-var">CWrapper</span></a></span><span> </span><span id="local-6989586621681188039"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681188039"><span class="hs-identifier hs-var">cconv</span></a></span></span><span> </span><span class="annot"><span class="annottext">Safety
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe Header
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-183"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Coercion -&gt; CCallConv -&gt; DsM ([Binding], SDoc, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsFExportDynamic"><span class="hs-identifier hs-var">dsFExportDynamic</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188042"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188041"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681188039"><span class="hs-identifier hs-var">cconv</span></a></span><span>
</span><span id="line-184"></span><span>
</span><span id="line-185"></span><span class="hs-comment">-- For stdcall labels, if the type was a FunPtr or newtype thereof,</span><span>
</span><span id="line-186"></span><span class="hs-comment">-- then we need to calculate the size of the arguments in order to add</span><span>
</span><span id="line-187"></span><span class="hs-comment">-- the @n suffix to the label.</span><span>
</span><span id="line-188"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#fun_type_arg_stdcall_info"><span class="hs-identifier hs-type">fun_type_arg_stdcall_info</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-type">CCallConv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-189"></span><span id="fun_type_arg_stdcall_info"><span class="annot"><span class="annottext">fun_type_arg_stdcall_info :: Platform -&gt; CCallConv -&gt; Type -&gt; Maybe Arity
</span><a href="GHC.HsToCore.Foreign.Decl.html#fun_type_arg_stdcall_info"><span class="hs-identifier hs-var hs-var">fun_type_arg_stdcall_info</span></a></span></span><span> </span><span id="local-6989586621681188037"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681188037"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#StdCallConv"><span class="hs-identifier hs-var">StdCallConv</span></a></span><span> </span><span id="local-6989586621681188035"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188035"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-190"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681188034"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188034"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span class="hs-special">[</span><span id="local-6989586621681188033"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188033"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188035"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-191"></span><span>    </span><span class="annot"><span class="annottext">TyCon -&gt; Unique
</span><a href="GHC.Core.TyCon.html#tyConUnique"><span class="hs-identifier hs-var hs-var">tyConUnique</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188034"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#funPtrTyConKey"><span class="hs-identifier hs-var">funPtrTyConKey</span></a></span><span>
</span><span id="line-192"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span>
</span><span id="line-193"></span><span>       </span><span class="hs-special">(</span><span id="local-6989586621681188031"><span class="annot"><span class="annottext">[TyBinder]
</span><a href="#local-6989586621681188031"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([TyBinder], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitPiTys"><span class="hs-identifier hs-var">tcSplitPiTys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188033"><span class="hs-identifier hs-var">arg_ty</span></a></span><span>
</span><span id="line-194"></span><span>       </span><span id="local-6989586621681188029"><span class="annot"><span class="annottext">fe_arg_tys :: [Type]
</span><a href="#local-6989586621681188029"><span class="hs-identifier hs-var hs-var">fe_arg_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyBinder -&gt; Maybe Type) -&gt; [TyBinder] -&gt; [Type]
forall a b. (a -&gt; Maybe b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/Data.Maybe.html#mapMaybe"><span class="hs-identifier hs-var">mapMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyBinder -&gt; Maybe Type
</span><a href="GHC.Core.Type.html#binderRelevantType_maybe"><span class="hs-identifier hs-var">binderRelevantType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">[TyBinder]
</span><a href="#local-6989586621681188031"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-195"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Arity -&gt; Maybe Arity
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(Arity -&gt; Maybe Arity) -&gt; Arity -&gt; Maybe Arity
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Arity] -&gt; Arity
forall (t :: * -&gt; *) a. (Foldable t, Num a) =&gt; t a -&gt; a
</span><a href="../../base/src/Data.Foldable.html#sum"><span class="hs-identifier hs-var">sum</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; Arity) -&gt; [Type] -&gt; [Arity]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Width -&gt; Arity
</span><a href="GHC.Cmm.Type.html#widthInBytes"><span class="hs-identifier hs-var">widthInBytes</span></a></span><span> </span><span class="annot"><span class="annottext">(Width -&gt; Arity) -&gt; (Type -&gt; Width) -&gt; Type -&gt; Arity
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; Width
</span><a href="GHC.Cmm.Type.html#typeWidth"><span class="hs-identifier hs-var">typeWidth</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmType -&gt; Width) -&gt; (Type -&gt; CmmType) -&gt; Type -&gt; Width
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Type -&gt; CmmType
</span><a href="GHC.Cmm.Utils.html#typeCmmType"><span class="hs-identifier hs-var">typeCmmType</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681188037"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; CmmType) -&gt; (Type -&gt; Type) -&gt; Type -&gt; CmmType
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="GHC.HsToCore.Foreign.Decl.html#getPrimTyOf"><span class="hs-identifier hs-var">getPrimTyOf</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681188029"><span class="hs-identifier hs-var">fe_arg_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-196"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#fun_type_arg_stdcall_info"><span class="hs-identifier hs-var">fun_type_arg_stdcall_info</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681188021"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681188021"><span class="hs-identifier hs-var">_other_conv</span></a></span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-197"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Arity
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-198"></span><span>
</span><span id="line-199"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Foreign calls}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-206"></span><span>
</span><span id="line-207"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsFCall"><span class="hs-identifier hs-type">dsFCall</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#ForeignCall"><span class="hs-identifier hs-type">ForeignCall</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#Header"><span class="hs-identifier hs-type">Header</span></a></span><span>
</span><span id="line-208"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier hs-type">Expr</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-209"></span><span id="dsFCall"><span class="annot"><span class="annottext">dsFCall :: Id
-&gt; Coercion
-&gt; ForeignCall
-&gt; Maybe Header
-&gt; DsM ([Binding], SDoc, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsFCall"><span class="hs-identifier hs-var hs-var">dsFCall</span></a></span></span><span> </span><span id="local-6989586621681188019"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188019"><span class="hs-identifier hs-var">fn_id</span></a></span></span><span> </span><span id="local-6989586621681188018"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188018"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621681188017"><span class="annot"><span class="annottext">ForeignCall
</span><a href="#local-6989586621681188017"><span class="hs-identifier hs-var">fcall</span></a></span></span><span> </span><span id="local-6989586621681188016"><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681188016"><span class="hs-identifier hs-var">mDeclHeader</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-210"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-211"></span><span>        </span><span id="local-6989586621681188015"><span class="annot"><span class="annottext">ty :: Type
</span><a href="#local-6989586621681188015"><span class="hs-identifier hs-var hs-var">ty</span></a></span></span><span>                   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type
</span><a href="GHC.Core.Coercion.html#coercionLKind"><span class="hs-identifier hs-var">coercionLKind</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188018"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-212"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681188014"><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681188014"><span class="hs-identifier hs-var">tv_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188013"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188013"><span class="hs-identifier hs-var">rho</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([TyVarBinder], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitForAllVarBndrs"><span class="hs-identifier hs-var">tcSplitForAllVarBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188015"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-213"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681188011"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681188011"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188010"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188010"><span class="hs-identifier hs-var">io_res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([Scaled Type], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitFunTys"><span class="hs-identifier hs-var">tcSplitFunTys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188013"><span class="hs-identifier hs-var">rho</span></a></span><span>
</span><span id="line-214"></span><span>
</span><span id="line-215"></span><span>    </span><span id="local-6989586621681188008"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681188008"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Scaled Type] -&gt; DsM [Id]
</span><a href="GHC.HsToCore.Monad.html#newSysLocalsDs"><span class="hs-identifier hs-var">newSysLocalsDs</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681188011"><span class="hs-identifier hs-var">arg_tys</span></a></span><span>  </span><span class="hs-comment">-- no FFI levity-polymorphism</span><span>
</span><span id="line-216"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681188006"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188006"><span class="hs-identifier hs-var">val_args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188005"><span class="annot"><span class="annottext">[CoreExpr -&gt; CoreExpr]
</span><a href="#local-6989586621681188005"><span class="hs-identifier hs-var">arg_wrappers</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CoreExpr
 -&gt; IOEnv (Env DsGblEnv DsLclEnv) (CoreExpr, CoreExpr -&gt; CoreExpr))
-&gt; [CoreExpr]
-&gt; IOEnv
     (Env DsGblEnv DsLclEnv) ([CoreExpr], [CoreExpr -&gt; CoreExpr])
forall (m :: * -&gt; *) a b c.
Applicative m =&gt;
(a -&gt; m (b, c)) -&gt; [a] -&gt; m ([b], [c])
</span><a href="../../base/src/Control.Monad.html#mapAndUnzipM"><span class="hs-identifier hs-var">mapAndUnzipM</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (CoreExpr, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#unboxArg"><span class="hs-identifier hs-var">unboxArg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; CoreExpr) -&gt; [Id] -&gt; [CoreExpr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681188008"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-217"></span><span>
</span><span id="line-218"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-219"></span><span>        </span><span id="local-6989586621681188001"><span class="annot"><span class="annottext">work_arg_ids :: [Id]
</span><a href="#local-6989586621681188001"><span class="hs-identifier hs-var hs-var">work_arg_ids</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188000"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621681188000"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188000"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188006"><span class="hs-identifier hs-var">val_args</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- All guaranteed to be vars</span><span>
</span><span id="line-220"></span><span>
</span><span id="line-221"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681187999"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187999"><span class="hs-identifier hs-var">ccall_result_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187998"><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681187998"><span class="hs-identifier hs-var">res_wrapper</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM (Type, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#boxResult"><span class="hs-identifier hs-var">boxResult</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188010"><span class="hs-identifier hs-var">io_res_ty</span></a></span><span>
</span><span id="line-222"></span><span>
</span><span id="line-223"></span><span>    </span><span id="local-6989586621681187996"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681187996"><span class="hs-identifier hs-var">ccall_uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf DsGblEnv DsLclEnv Unique
forall gbl lcl. TcRnIf gbl lcl Unique
</span><a href="GHC.Tc.Utils.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-224"></span><span>    </span><span id="local-6989586621681187994"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681187994"><span class="hs-identifier hs-var">work_uniq</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf DsGblEnv DsLclEnv Unique
forall gbl lcl. TcRnIf gbl lcl Unique
</span><a href="GHC.Tc.Utils.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-225"></span><span>
</span><span id="line-226"></span><span>    </span><span id="local-6989586621681187993"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187993"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-227"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681187992"><span class="annot"><span class="annottext">ForeignCall
</span><a href="#local-6989586621681187992"><span class="hs-identifier hs-var">fcall'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187991"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187991"><span class="hs-identifier hs-var">cDoc</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-228"></span><span>              </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ForeignCall
</span><a href="#local-6989586621681188017"><span class="hs-identifier hs-var">fcall</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-229"></span><span>              </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCall"><span class="hs-identifier hs-type">CCall</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCallSpec"><span class="hs-identifier hs-type">CCallSpec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.ForeignCall.html#StaticTarget"><span class="hs-identifier hs-type">StaticTarget</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681187989"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187989"><span class="hs-identifier hs-var">cName</span></a></span></span><span> </span><span id="local-6989586621681187988"><span class="annot"><span class="annottext">Maybe Unit
</span><a href="#local-6989586621681187988"><span class="hs-identifier hs-var">mUnitId</span></a></span></span><span> </span><span id="local-6989586621681187987"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187987"><span class="hs-identifier hs-var">isFun</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-230"></span><span>                               </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#CApiConv"><span class="hs-identifier hs-var">CApiConv</span></a></span><span> </span><span id="local-6989586621681187985"><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681187985"><span class="hs-identifier hs-var">safety</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-231"></span><span>               </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681187984"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187984"><span class="hs-identifier hs-var">wrapperName</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; IOEnv (Env DsGblEnv DsLclEnv) CLabelString
forall (m :: * -&gt; *).
(MonadIO m, HasDynFlags m, HasModule m) =&gt;
String -&gt; String -&gt; m CLabelString
</span><a href="GHC.Tc.Utils.Env.html#mkWrapperName"><span class="hs-identifier hs-var">mkWrapperName</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ghc_wrapper&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabelString -&gt; String
</span><a href="GHC.Data.FastString.html#unpackFS"><span class="hs-identifier hs-var">unpackFS</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187989"><span class="hs-identifier hs-var">cName</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-232"></span><span>                  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681187981"><span class="annot"><span class="annottext">fcall' :: ForeignCall
</span><a href="#local-6989586621681187981"><span class="hs-identifier hs-var hs-var">fcall'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CCallSpec -&gt; ForeignCall
</span><a href="GHC.Types.ForeignCall.html#CCall"><span class="hs-identifier hs-var">CCall</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CCallTarget -&gt; CCallConv -&gt; Safety -&gt; CCallSpec
</span><a href="GHC.Types.ForeignCall.html#CCallSpec"><span class="hs-identifier hs-var">CCallSpec</span></a></span><span>
</span><span id="line-233"></span><span>                                      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SourceText -&gt; CLabelString -&gt; Maybe Unit -&gt; Bool -&gt; CCallTarget
</span><a href="GHC.Types.ForeignCall.html#StaticTarget"><span class="hs-identifier hs-var">StaticTarget</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><a href="GHC.Types.Basic.html#NoSourceText"><span class="hs-identifier hs-var">NoSourceText</span></a></span><span>
</span><span id="line-234"></span><span>                                                    </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187984"><span class="hs-identifier hs-var">wrapperName</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Unit
</span><a href="#local-6989586621681187988"><span class="hs-identifier hs-var">mUnitId</span></a></span><span>
</span><span id="line-235"></span><span>                                                    </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span>
</span><span id="line-236"></span><span>                                      </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#CApiConv"><span class="hs-identifier hs-var">CApiConv</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681187985"><span class="hs-identifier hs-var">safety</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-237"></span><span>                      </span><span id="local-6989586621681187979"><span class="annot"><span class="annottext">c :: SDoc
</span><a href="#local-6989586621681187979"><span class="hs-identifier hs-var hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187978"><span class="hs-identifier hs-var">includes</span></a></span><span>
</span><span id="line-238"></span><span>                       </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187977"><span class="hs-identifier hs-var">fun_proto</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187975"><span class="hs-identifier hs-var">cRet</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#semi"><span class="hs-identifier hs-var">semi</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-239"></span><span>                      </span><span id="local-6989586621681187978"><span class="annot"><span class="annottext">includes :: SDoc
</span><a href="#local-6989586621681187978"><span class="hs-identifier hs-var hs-var">includes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;#include \&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ftext"><span class="hs-identifier hs-var">ftext</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187971"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-240"></span><span>                                        </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\&quot;&quot;</span></span><span>
</span><span id="line-241"></span><span>                                      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#Header"><span class="hs-identifier hs-type">Header</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681187971"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187971"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Header] -&gt; [Header]
forall a. Eq a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#nub"><span class="hs-identifier hs-var">nub</span></a></span><span> </span><span class="annot"><span class="annottext">[Header]
</span><a href="#local-6989586621681187968"><span class="hs-identifier hs-var">headers</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-242"></span><span>                      </span><span id="local-6989586621681187977"><span class="annot"><span class="annottext">fun_proto :: SDoc
</span><a href="#local-6989586621681187977"><span class="hs-identifier hs-var hs-var">fun_proto</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187967"><span class="hs-identifier hs-var">cResType</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187966"><span class="hs-identifier hs-var">pprCconv</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187984"><span class="hs-identifier hs-var">wrapperName</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187964"><span class="hs-identifier hs-var">argTypes</span></a></span><span>
</span><span id="line-243"></span><span>                      </span><span id="local-6989586621681187975"><span class="annot"><span class="annottext">cRet :: SDoc
</span><a href="#local-6989586621681187975"><span class="hs-identifier hs-var hs-var">cRet</span></a></span></span><span>
</span><span id="line-244"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187963"><span class="hs-identifier hs-var">isVoidRes</span></a></span><span> </span><span class="hs-glyph">=</span><span>                   </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187962"><span class="hs-identifier hs-var">cCall</span></a></span><span>
</span><span id="line-245"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;return&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187962"><span class="hs-identifier hs-var">cCall</span></a></span><span>
</span><span id="line-246"></span><span>                      </span><span id="local-6989586621681187962"><span class="annot"><span class="annottext">cCall :: SDoc
</span><a href="#local-6989586621681187962"><span class="hs-identifier hs-var hs-var">cCall</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187987"><span class="hs-identifier hs-var">isFun</span></a></span><span>
</span><span id="line-247"></span><span>                              </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">CLabelString -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187989"><span class="hs-identifier hs-var">cName</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187961"><span class="hs-identifier hs-var">argVals</span></a></span><span>
</span><span id="line-248"></span><span>                              </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[Scaled Type] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681188011"><span class="hs-identifier hs-var">arg_tys</span></a></span><span>
</span><span id="line-249"></span><span>                                    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">CLabelString -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187989"><span class="hs-identifier hs-var">cName</span></a></span><span>
</span><span id="line-250"></span><span>                                    </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dsFCall: Unexpected arguments to FFI value import&quot;</span></span><span>
</span><span id="line-251"></span><span>                      </span><span id="local-6989586621681187958"><span class="annot"><span class="annottext">raw_res_ty :: Type
</span><a href="#local-6989586621681187958"><span class="hs-identifier hs-var hs-var">raw_res_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (TyCon, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitIOType_maybe"><span class="hs-identifier hs-var">tcSplitIOType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188010"><span class="hs-identifier hs-var">io_res_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-252"></span><span>                                   </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681187956"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187956"><span class="hs-identifier hs-var">_ioTyCon</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187955"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187955"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187955"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-253"></span><span>                                   </span><span class="annot"><span class="annottext">Maybe (TyCon, Type)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188010"><span class="hs-identifier hs-var">io_res_ty</span></a></span><span>
</span><span id="line-254"></span><span>                      </span><span id="local-6989586621681187963"><span class="annot"><span class="annottext">isVoidRes :: Bool
</span><a href="#local-6989586621681187963"><span class="hs-identifier hs-var hs-var">isVoidRes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187958"><span class="hs-identifier hs-var">raw_res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Bool
</span><a href="GHC.Core.Type.html#eqType"><span class="hs-operator hs-var">`eqType`</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#unitTy"><span class="hs-identifier hs-var">unitTy</span></a></span><span>
</span><span id="line-255"></span><span>                      </span><span class="hs-special">(</span><span id="local-6989586621681187953"><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681187953"><span class="hs-identifier hs-var">mHeader</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187967"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187967"><span class="hs-identifier hs-var">cResType</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-256"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187963"><span class="hs-identifier hs-var">isVoidRes</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Header
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;void&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-257"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; (Maybe Header, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#toCType"><span class="hs-identifier hs-var">toCType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187958"><span class="hs-identifier hs-var">raw_res_ty</span></a></span><span>
</span><span id="line-258"></span><span>                      </span><span id="local-6989586621681187966"><span class="annot"><span class="annottext">pprCconv :: SDoc
</span><a href="#local-6989586621681187966"><span class="hs-identifier hs-var hs-var">pprCconv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CCallConv -&gt; SDoc
</span><a href="GHC.Types.ForeignCall.html#ccallConvAttribute"><span class="hs-identifier hs-var">ccallConvAttribute</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#CApiConv"><span class="hs-identifier hs-var">CApiConv</span></a></span><span>
</span><span id="line-259"></span><span>                      </span><span id="local-6989586621681187950"><span class="annot"><span class="annottext">mHeadersArgTypeList :: [(Maybe Header, SDoc)]
</span><a href="#local-6989586621681187950"><span class="hs-identifier hs-var hs-var">mHeadersArgTypeList</span></a></span></span><span>
</span><span id="line-260"></span><span>                          </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681187949"><span class="hs-identifier hs-var">header</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187948"><span class="hs-identifier hs-var">cType</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'a'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Arity -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187945"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-261"></span><span>                            </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681187944"><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621681187944"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187945"><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187945"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Scaled Type] -&gt; [Arity] -&gt; [(Scaled Type, Arity)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681188011"><span class="hs-identifier hs-var">arg_tys</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">1</span></span><span class="hs-glyph">..</span><span class="hs-special">]</span><span>
</span><span id="line-262"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681187949"><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681187949"><span class="hs-identifier hs-var">header</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187948"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187948"><span class="hs-identifier hs-var">cType</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; (Maybe Header, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#toCType"><span class="hs-identifier hs-var">toCType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Scaled Type -&gt; Type
forall a. Scaled a -&gt; a
</span><a href="GHC.Core.TyCo.Rep.html#scaledThing"><span class="hs-identifier hs-var">scaledThing</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621681187944"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-263"></span><span>                      </span><span class="hs-special">(</span><span id="local-6989586621681187942"><span class="annot"><span class="annottext">[Maybe Header]
</span><a href="#local-6989586621681187942"><span class="hs-identifier hs-var">mHeaders</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187941"><span class="annot"><span class="annottext">[SDoc]
</span><a href="#local-6989586621681187941"><span class="hs-identifier hs-var">argTypeList</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Maybe Header, SDoc)] -&gt; ([Maybe Header], [SDoc])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">[(Maybe Header, SDoc)]
</span><a href="#local-6989586621681187950"><span class="hs-identifier hs-var">mHeadersArgTypeList</span></a></span><span>
</span><span id="line-264"></span><span>                      </span><span id="local-6989586621681187964"><span class="annot"><span class="annottext">argTypes :: SDoc
</span><a href="#local-6989586621681187964"><span class="hs-identifier hs-var hs-var">argTypes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc]
</span><a href="#local-6989586621681187941"><span class="hs-identifier hs-var">argTypeList</span></a></span><span>
</span><span id="line-265"></span><span>                                 </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;void&quot;</span></span><span>
</span><span id="line-266"></span><span>                                 </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; [SDoc] -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; [SDoc] -&gt; [SDoc]
</span><a href="GHC.Utils.Outputable.html#punctuate"><span class="hs-identifier hs-var">punctuate</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc]
</span><a href="#local-6989586621681187941"><span class="hs-identifier hs-var">argTypeList</span></a></span><span>
</span><span id="line-267"></span><span>                      </span><span id="local-6989586621681187936"><span class="annot"><span class="annottext">mHeaders' :: [Maybe Header]
</span><a href="#local-6989586621681187936"><span class="hs-identifier hs-var hs-var">mHeaders'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681188016"><span class="hs-identifier hs-var">mDeclHeader</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Header -&gt; [Maybe Header] -&gt; [Maybe Header]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681187953"><span class="hs-identifier hs-var">mHeader</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Header -&gt; [Maybe Header] -&gt; [Maybe Header]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Maybe Header]
</span><a href="#local-6989586621681187942"><span class="hs-identifier hs-var">mHeaders</span></a></span><span>
</span><span id="line-268"></span><span>                      </span><span id="local-6989586621681187968"><span class="annot"><span class="annottext">headers :: [Header]
</span><a href="#local-6989586621681187968"><span class="hs-identifier hs-var hs-var">headers</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Maybe Header] -&gt; [Header]
forall a. [Maybe a] -&gt; [a]
</span><a href="../../base/src/Data.Maybe.html#catMaybes"><span class="hs-identifier hs-var">catMaybes</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe Header]
</span><a href="#local-6989586621681187936"><span class="hs-identifier hs-var">mHeaders'</span></a></span><span>
</span><span id="line-269"></span><span>                      </span><span id="local-6989586621681187961"><span class="annot"><span class="annottext">argVals :: SDoc
</span><a href="#local-6989586621681187961"><span class="hs-identifier hs-var hs-var">argVals</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; [SDoc] -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; [SDoc] -&gt; [SDoc]
</span><a href="GHC.Utils.Outputable.html#punctuate"><span class="hs-identifier hs-var">punctuate</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span>
</span><span id="line-270"></span><span>                                    </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'a'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Arity -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187934"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-271"></span><span>                                    </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Scaled Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187934"><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187934"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Scaled Type] -&gt; [Arity] -&gt; [(Scaled Type, Arity)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681188011"><span class="hs-identifier hs-var">arg_tys</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">1</span></span><span class="hs-glyph">..</span><span class="hs-special">]</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-272"></span><span>                  </span><span class="annot"><span class="annottext">(ForeignCall, SDoc)
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (ForeignCall, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignCall
</span><a href="#local-6989586621681187981"><span class="hs-identifier hs-var">fcall'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187979"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-273"></span><span>              </span><span class="annot"><span class="annottext">ForeignCall
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-274"></span><span>                  </span><span class="annot"><span class="annottext">(ForeignCall, SDoc)
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (ForeignCall, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignCall
</span><a href="#local-6989586621681188017"><span class="hs-identifier hs-var">fcall</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-275"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-276"></span><span>        </span><span class="hs-comment">-- Build the worker</span><span>
</span><span id="line-277"></span><span>        </span><span id="local-6989586621681187933"><span class="annot"><span class="annottext">worker_ty :: Type
</span><a href="#local-6989586621681187933"><span class="hs-identifier hs-var hs-var">worker_ty</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyVarBinder] -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkForAllTys"><span class="hs-identifier hs-var">mkForAllTys</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681188014"><span class="hs-identifier hs-var">tv_bndrs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTysMany"><span class="hs-identifier hs-var">mkVisFunTysMany</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; Type) -&gt; [Id] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681188001"><span class="hs-identifier hs-var">work_arg_ids</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187999"><span class="hs-identifier hs-var">ccall_result_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-278"></span><span>        </span><span id="local-6989586621681187929"><span class="annot"><span class="annottext">tvs :: [Id]
</span><a href="#local-6989586621681187929"><span class="hs-identifier hs-var hs-var">tvs</span></a></span></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyVarBinder -&gt; Id) -&gt; [TyVarBinder] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">TyVarBinder -&gt; Id
forall tv argf. VarBndr tv argf -&gt; tv
</span><a href="GHC.Types.Var.html#binderVar"><span class="hs-identifier hs-var">binderVar</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681188014"><span class="hs-identifier hs-var">tv_bndrs</span></a></span><span>
</span><span id="line-279"></span><span>        </span><span id="local-6989586621681187927"><span class="annot"><span class="annottext">the_ccall_app :: CoreExpr
</span><a href="#local-6989586621681187927"><span class="hs-identifier hs-var hs-var">the_ccall_app</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Unique -&gt; ForeignCall -&gt; [CoreExpr] -&gt; Type -&gt; CoreExpr
</span><a href="GHC.HsToCore.Foreign.Call.html#mkFCall"><span class="hs-identifier hs-var">mkFCall</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187993"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681187996"><span class="hs-identifier hs-var">ccall_uniq</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignCall
</span><a href="#local-6989586621681187992"><span class="hs-identifier hs-var">fcall'</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188006"><span class="hs-identifier hs-var">val_args</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187999"><span class="hs-identifier hs-var">ccall_result_ty</span></a></span><span>
</span><span id="line-280"></span><span>        </span><span id="local-6989586621681187925"><span class="annot"><span class="annottext">work_rhs :: CoreExpr
</span><a href="#local-6989586621681187925"><span class="hs-identifier hs-var hs-var">work_rhs</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; CoreExpr -&gt; CoreExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187929"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; CoreExpr -&gt; CoreExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681188001"><span class="hs-identifier hs-var">work_arg_ids</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187927"><span class="hs-identifier hs-var">the_ccall_app</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-281"></span><span>        </span><span id="local-6989586621681187923"><span class="annot"><span class="annottext">work_id :: Id
</span><a href="#local-6989586621681187923"><span class="hs-identifier hs-var hs-var">work_id</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CLabelString -&gt; Unique -&gt; Type -&gt; Type -&gt; Id
</span><a href="GHC.Types.Id.html#mkSysLocal"><span class="hs-identifier hs-var">mkSysLocal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CLabelString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;$wccall&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681187994"><span class="hs-identifier hs-var">work_uniq</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187933"><span class="hs-identifier hs-var">worker_ty</span></a></span><span>
</span><span id="line-282"></span><span>
</span><span id="line-283"></span><span>        </span><span class="hs-comment">-- Build the wrapper</span><span>
</span><span id="line-284"></span><span>        </span><span id="local-6989586621681187919"><span class="annot"><span class="annottext">work_app :: CoreExpr
</span><a href="#local-6989586621681187919"><span class="hs-identifier hs-var hs-var">work_app</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
forall b. Expr b -&gt; [Expr b] -&gt; Expr b
</span><a href="GHC.Core.html#mkApps"><span class="hs-identifier hs-var">mkApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; [Id] -&gt; CoreExpr
forall b. Expr b -&gt; [Id] -&gt; Expr b
</span><a href="GHC.Core.html#mkVarApps"><span class="hs-identifier hs-var">mkVarApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187923"><span class="hs-identifier hs-var">work_id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187929"><span class="hs-identifier hs-var">tvs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188006"><span class="hs-identifier hs-var">val_args</span></a></span><span>
</span><span id="line-285"></span><span>        </span><span id="local-6989586621681187916"><span class="annot"><span class="annottext">wrapper_body :: CoreExpr
</span><a href="#local-6989586621681187916"><span class="hs-identifier hs-var hs-var">wrapper_body</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((CoreExpr -&gt; CoreExpr) -&gt; CoreExpr -&gt; CoreExpr)
-&gt; CoreExpr -&gt; [CoreExpr -&gt; CoreExpr] -&gt; CoreExpr
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; CoreExpr -&gt; CoreExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">($)</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681187998"><span class="hs-identifier hs-var">res_wrapper</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187919"><span class="hs-identifier hs-var">work_app</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExpr -&gt; CoreExpr]
</span><a href="#local-6989586621681188005"><span class="hs-identifier hs-var">arg_wrappers</span></a></span><span>
</span><span id="line-286"></span><span>        </span><span id="local-6989586621681187915"><span class="annot"><span class="annottext">wrap_rhs :: CoreExpr
</span><a href="#local-6989586621681187915"><span class="hs-identifier hs-var hs-var">wrap_rhs</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; CoreExpr -&gt; CoreExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187929"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [Id]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681188008"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187916"><span class="hs-identifier hs-var">wrapper_body</span></a></span><span>
</span><span id="line-287"></span><span>        </span><span id="local-6989586621681187914"><span class="annot"><span class="annottext">wrap_rhs' :: CoreExpr
</span><a href="#local-6989586621681187914"><span class="hs-identifier hs-var hs-var">wrap_rhs'</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Coercion -&gt; CoreExpr
forall b. Expr b -&gt; Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187915"><span class="hs-identifier hs-var">wrap_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188018"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-288"></span><span>        </span><span id="local-6989586621681187913"><span class="annot"><span class="annottext">fn_id_w_inl :: Id
</span><a href="#local-6989586621681187913"><span class="hs-identifier hs-var hs-var">fn_id_w_inl</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681188019"><span class="hs-identifier hs-var">fn_id</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Unfolding -&gt; Id
</span><a href="GHC.Types.Id.html#setIdUnfolding"><span class="hs-operator hs-var">`setIdUnfolding`</span></a></span><span> </span><span class="annot"><span class="annottext">Arity -&gt; CoreExpr -&gt; Unfolding
</span><a href="GHC.Core.Unfold.html#mkInlineUnfoldingWithArity"><span class="hs-identifier hs-var">mkInlineUnfoldingWithArity</span></a></span><span>
</span><span id="line-289"></span><span>                                                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; Arity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Arity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681188008"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187914"><span class="hs-identifier hs-var">wrap_rhs'</span></a></span><span>
</span><span id="line-290"></span><span>
</span><span id="line-291"></span><span>    </span><span class="annot"><span class="annottext">([Binding], SDoc, SDoc) -&gt; DsM ([Binding], SDoc, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187923"><span class="hs-identifier hs-var">work_id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187925"><span class="hs-identifier hs-var">work_rhs</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187913"><span class="hs-identifier hs-var">fn_id_w_inl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187914"><span class="hs-identifier hs-var">wrap_rhs'</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187991"><span class="hs-identifier hs-var">cDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-292"></span><span>
</span><span id="line-293"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Primitive calls}
*                                                                      *
************************************************************************

This is for `@foreign import prim@' declarations.

Currently, at the core level we pretend that these primitive calls are
foreign calls. It may make more sense in future to have them as a distinct
kind of Id, or perhaps to bundle them with PrimOps since semantically and
for calling convention they are really prim ops.
-}</span><span>
</span><span id="line-307"></span><span>
</span><span id="line-308"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsPrimCall"><span class="hs-identifier hs-type">dsPrimCall</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#ForeignCall"><span class="hs-identifier hs-type">ForeignCall</span></a></span><span>
</span><span id="line-309"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier hs-type">Expr</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-310"></span><span id="dsPrimCall"><span class="annot"><span class="annottext">dsPrimCall :: Id -&gt; Coercion -&gt; ForeignCall -&gt; DsM ([Binding], SDoc, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsPrimCall"><span class="hs-identifier hs-var hs-var">dsPrimCall</span></a></span></span><span> </span><span id="local-6989586621681187909"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187909"><span class="hs-identifier hs-var">fn_id</span></a></span></span><span> </span><span id="local-6989586621681187908"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681187908"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621681187907"><span class="annot"><span class="annottext">ForeignCall
</span><a href="#local-6989586621681187907"><span class="hs-identifier hs-var">fcall</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-311"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-312"></span><span>        </span><span id="local-6989586621681187906"><span class="annot"><span class="annottext">ty :: Type
</span><a href="#local-6989586621681187906"><span class="hs-identifier hs-var hs-var">ty</span></a></span></span><span>                   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type
</span><a href="GHC.Core.Coercion.html#coercionLKind"><span class="hs-identifier hs-var">coercionLKind</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681187908"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-313"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681187905"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187905"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187904"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187904"><span class="hs-identifier hs-var">fun_ty</span></a></span></span><span class="hs-special">)</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([Id], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitForAllTys"><span class="hs-identifier hs-var">tcSplitForAllTys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187906"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-314"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681187902"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681187902"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187901"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187901"><span class="hs-identifier hs-var">io_res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([Scaled Type], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitFunTys"><span class="hs-identifier hs-var">tcSplitFunTys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187904"><span class="hs-identifier hs-var">fun_ty</span></a></span><span>
</span><span id="line-315"></span><span>
</span><span id="line-316"></span><span>    </span><span id="local-6989586621681187900"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187900"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Scaled Type] -&gt; DsM [Id]
</span><a href="GHC.HsToCore.Monad.html#newSysLocalsDs"><span class="hs-identifier hs-var">newSysLocalsDs</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681187902"><span class="hs-identifier hs-var">arg_tys</span></a></span><span>  </span><span class="hs-comment">-- no FFI levity-polymorphism</span><span>
</span><span id="line-317"></span><span>
</span><span id="line-318"></span><span>    </span><span id="local-6989586621681187899"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681187899"><span class="hs-identifier hs-var">ccall_uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf DsGblEnv DsLclEnv Unique
forall gbl lcl. TcRnIf gbl lcl Unique
</span><a href="GHC.Tc.Utils.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-319"></span><span>    </span><span id="local-6989586621681187898"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187898"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-320"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-321"></span><span>        </span><span id="local-6989586621681187897"><span class="annot"><span class="annottext">call_app :: CoreExpr
</span><a href="#local-6989586621681187897"><span class="hs-identifier hs-var hs-var">call_app</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Unique -&gt; ForeignCall -&gt; [CoreExpr] -&gt; Type -&gt; CoreExpr
</span><a href="GHC.HsToCore.Foreign.Call.html#mkFCall"><span class="hs-identifier hs-var">mkFCall</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187898"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681187899"><span class="hs-identifier hs-var">ccall_uniq</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignCall
</span><a href="#local-6989586621681187907"><span class="hs-identifier hs-var">fcall</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; CoreExpr) -&gt; [Id] -&gt; [CoreExpr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187900"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187901"><span class="hs-identifier hs-var">io_res_ty</span></a></span><span>
</span><span id="line-322"></span><span>        </span><span id="local-6989586621681187896"><span class="annot"><span class="annottext">rhs :: CoreExpr
</span><a href="#local-6989586621681187896"><span class="hs-identifier hs-var hs-var">rhs</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; CoreExpr -&gt; CoreExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187905"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; CoreExpr -&gt; CoreExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187900"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187897"><span class="hs-identifier hs-var">call_app</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-323"></span><span>        </span><span id="local-6989586621681187895"><span class="annot"><span class="annottext">rhs' :: CoreExpr
</span><a href="#local-6989586621681187895"><span class="hs-identifier hs-var hs-var">rhs'</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Coercion -&gt; CoreExpr
forall b. Expr b -&gt; Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187896"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681187908"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-324"></span><span>    </span><span class="annot"><span class="annottext">([Binding], SDoc, SDoc) -&gt; DsM ([Binding], SDoc, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187909"><span class="hs-identifier hs-var">fn_id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187895"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-325"></span><span>
</span><span id="line-326"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Foreign export}
*                                                                      *
************************************************************************

The function that does most of the work for `@foreign export@' declarations.
(see below for the boilerplate code a `@foreign export@' declaration expands
 into.)

For each `@foreign export foo@' in a module M we generate:
\begin{itemize}
\item a C function `@foo@', which calls
\item a Haskell stub `@M.\$ffoo@', which calls
\end{itemize}
the user-written Haskell function `@M.foo@'.
-}</span><span>
</span><span id="line-344"></span><span>
</span><span id="line-345"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsFExport"><span class="hs-identifier hs-type">dsFExport</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>                 </span><span class="hs-comment">-- Either the exported Id,</span><span>
</span><span id="line-346"></span><span>                                </span><span class="hs-comment">-- or the foreign-export-dynamic constructor</span><span>
</span><span id="line-347"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>           </span><span class="hs-comment">-- Coercion between the Haskell type callable</span><span>
</span><span id="line-348"></span><span>                                </span><span class="hs-comment">-- from C, and its representation type</span><span>
</span><span id="line-349"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CLabelString"><span class="hs-identifier hs-type">CLabelString</span></a></span><span>       </span><span class="hs-comment">-- The name to export to C land</span><span>
</span><span id="line-350"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-type">CCallConv</span></a></span><span>
</span><span id="line-351"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>               </span><span class="hs-comment">-- True =&gt; foreign export dynamic</span><span>
</span><span id="line-352"></span><span>                                </span><span class="hs-comment">--         so invoke IO action that's hanging off</span><span>
</span><span id="line-353"></span><span>                                </span><span class="hs-comment">--         the first argument's stable pointer</span><span>
</span><span id="line-354"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>         </span><span class="hs-comment">-- contents of Module_stub.h</span><span>
</span><span id="line-355"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>         </span><span class="hs-comment">-- contents of Module_stub.c</span><span>
</span><span id="line-356"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>       </span><span class="hs-comment">-- string describing type to pass to createAdj.</span><span>
</span><span id="line-357"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>          </span><span class="hs-comment">-- size of args to stub function</span><span>
</span><span id="line-358"></span><span>                 </span><span class="hs-special">)</span><span>
</span><span id="line-359"></span><span>
</span><span id="line-360"></span><span id="dsFExport"><span class="annot"><span class="annottext">dsFExport :: Id
-&gt; Coercion
-&gt; CLabelString
-&gt; CCallConv
-&gt; Bool
-&gt; DsM (SDoc, SDoc, String, Arity)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsFExport"><span class="hs-identifier hs-var hs-var">dsFExport</span></a></span></span><span> </span><span id="local-6989586621681187894"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187894"><span class="hs-identifier hs-var">fn_id</span></a></span></span><span> </span><span id="local-6989586621681187893"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681187893"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621681187892"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187892"><span class="hs-identifier hs-var">ext_name</span></a></span></span><span> </span><span id="local-6989586621681187891"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681187891"><span class="hs-identifier hs-var">cconv</span></a></span></span><span> </span><span id="local-6989586621681187890"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187890"><span class="hs-identifier hs-var">isDyn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-361"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-362"></span><span>       </span><span id="local-6989586621681187889"><span class="annot"><span class="annottext">ty :: Type
</span><a href="#local-6989586621681187889"><span class="hs-identifier hs-var hs-var">ty</span></a></span></span><span>                     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type
</span><a href="GHC.Core.Coercion.html#coercionRKind"><span class="hs-identifier hs-var">coercionRKind</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681187893"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-363"></span><span>       </span><span class="hs-special">(</span><span id="local-6989586621681187887"><span class="annot"><span class="annottext">[TyBinder]
</span><a href="#local-6989586621681187887"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187886"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187886"><span class="hs-identifier hs-var">orig_res_ty</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([TyBinder], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitPiTys"><span class="hs-identifier hs-var">tcSplitPiTys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187889"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-364"></span><span>       </span><span id="local-6989586621681187885"><span class="annot"><span class="annottext">fe_arg_tys' :: [Type]
</span><a href="#local-6989586621681187885"><span class="hs-identifier hs-var hs-var">fe_arg_tys'</span></a></span></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyBinder -&gt; Maybe Type) -&gt; [TyBinder] -&gt; [Type]
forall a b. (a -&gt; Maybe b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/Data.Maybe.html#mapMaybe"><span class="hs-identifier hs-var">mapMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyBinder -&gt; Maybe Type
</span><a href="GHC.Core.Type.html#binderRelevantType_maybe"><span class="hs-identifier hs-var">binderRelevantType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">[TyBinder]
</span><a href="#local-6989586621681187887"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-365"></span><span>       </span><span class="hs-comment">-- We must use tcSplits here, because we want to see</span><span>
</span><span id="line-366"></span><span>       </span><span class="hs-comment">-- the (IO t) in the corner of the type!</span><span>
</span><span id="line-367"></span><span>       </span><span id="local-6989586621681187884"><span class="annot"><span class="annottext">fe_arg_tys :: [Type]
</span><a href="#local-6989586621681187884"><span class="hs-identifier hs-var hs-var">fe_arg_tys</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187890"><span class="hs-identifier hs-var">isDyn</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#tail"><span class="hs-identifier hs-var">tail</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681187885"><span class="hs-identifier hs-var">fe_arg_tys'</span></a></span><span>
</span><span id="line-368"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681187885"><span class="hs-identifier hs-var">fe_arg_tys'</span></a></span><span>
</span><span id="line-369"></span><span>
</span><span id="line-370"></span><span>       </span><span class="hs-comment">-- Look at the result type of the exported function, orig_res_ty</span><span>
</span><span id="line-371"></span><span>       </span><span class="hs-comment">-- If it's IO t, return         (t, True)</span><span>
</span><span id="line-372"></span><span>       </span><span class="hs-comment">-- If it's plain t, return      (t, False)</span><span>
</span><span id="line-373"></span><span>       </span><span class="hs-special">(</span><span id="local-6989586621681187882"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187882"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187881"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187881"><span class="hs-identifier hs-var">is_IO_res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (TyCon, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitIOType_maybe"><span class="hs-identifier hs-var">tcSplitIOType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187886"><span class="hs-identifier hs-var">orig_res_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-374"></span><span>                                </span><span class="hs-comment">-- The function already returns IO t</span><span>
</span><span id="line-375"></span><span>                                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681187880"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187880"><span class="hs-identifier hs-var">_ioTyCon</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187879"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187879"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187879"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span>
</span><span id="line-376"></span><span>                                </span><span class="hs-comment">-- The function returns t</span><span>
</span><span id="line-377"></span><span>                                </span><span class="annot"><span class="annottext">Maybe (TyCon, Type)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187886"><span class="hs-identifier hs-var">orig_res_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-378"></span><span>
</span><span id="line-379"></span><span>    </span><span id="local-6989586621681187878"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187878"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-380"></span><span>    </span><span class="annot"><span class="annottext">(SDoc, SDoc, String, Arity) -&gt; DsM (SDoc, SDoc, String, Arity)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">((SDoc, SDoc, String, Arity) -&gt; DsM (SDoc, SDoc, String, Arity))
-&gt; (SDoc, SDoc, String, Arity) -&gt; DsM (SDoc, SDoc, String, Arity)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-381"></span><span>      </span><span class="annot"><span class="annottext">DynFlags
-&gt; CLabelString
-&gt; Maybe Id
-&gt; [Type]
-&gt; Type
-&gt; Bool
-&gt; CCallConv
-&gt; (SDoc, SDoc, String, Arity)
</span><a href="GHC.HsToCore.Foreign.Decl.html#mkFExportCBits"><span class="hs-identifier hs-var">mkFExportCBits</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187878"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187892"><span class="hs-identifier hs-var">ext_name</span></a></span><span>
</span><span id="line-382"></span><span>                     </span><span class="hs-special">(</span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187890"><span class="hs-identifier hs-var">isDyn</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe Id
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe Id
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187894"><span class="hs-identifier hs-var">fn_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-383"></span><span>                     </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681187884"><span class="hs-identifier hs-var">fe_arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187882"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187881"><span class="hs-identifier hs-var">is_IO_res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681187891"><span class="hs-identifier hs-var">cconv</span></a></span><span>
</span><span id="line-384"></span><span>
</span><span id="line-385"></span><span class="hs-comment">{-
@foreign import &quot;wrapper&quot;@ (previously &quot;foreign export dynamic&quot;) lets
you dress up Haskell IO actions of some fixed type behind an
externally callable interface (i.e., as a C function pointer). Useful
for callbacks and stuff.

\begin{verbatim}
type Fun = Bool -&gt; Int -&gt; IO Int
foreign import &quot;wrapper&quot; f :: Fun -&gt; IO (FunPtr Fun)

-- Haskell-visible constructor, which is generated from the above:
-- SUP: No check for NULL from createAdjustor anymore???

f :: Fun -&gt; IO (FunPtr Fun)
f cback =
   bindIO (newStablePtr cback)
          (\StablePtr sp# -&gt; IO (\s1# -&gt;
              case _ccall_ createAdjustor cconv sp# ``f_helper'' &lt;arg info&gt; s1# of
                 (# s2#, a# #) -&gt; (# s2#, A# a# #)))

foreign import &quot;&amp;f_helper&quot; f_helper :: FunPtr (StablePtr Fun -&gt; Fun)

-- and the helper in C: (approximately; see `mkFExportCBits` below)

f_helper(StablePtr s, HsBool b, HsInt i)
{
        Capability *cap;
        cap = rts_lock();
        rts_evalIO(&amp;cap,
                   rts_apply(rts_apply(deRefStablePtr(s),
                                       rts_mkBool(b)), rts_mkInt(i)));
        rts_unlock(cap);
}
\end{verbatim}
-}</span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#dsFExportDynamic"><span class="hs-identifier hs-type">dsFExportDynamic</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-422"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-423"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-type">CCallConv</span></a></span><span>
</span><span id="line-424"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#Binding"><span class="hs-identifier hs-type">Binding</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-425"></span><span id="dsFExportDynamic"><span class="annot"><span class="annottext">dsFExportDynamic :: Id -&gt; Coercion -&gt; CCallConv -&gt; DsM ([Binding], SDoc, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsFExportDynamic"><span class="hs-identifier hs-var hs-var">dsFExportDynamic</span></a></span></span><span> </span><span id="local-6989586621681187876"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187876"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621681187875"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681187875"><span class="hs-identifier hs-var">co0</span></a></span></span><span> </span><span id="local-6989586621681187874"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681187874"><span class="hs-identifier hs-var">cconv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-426"></span><span>    </span><span id="local-6989586621681187873"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681187873"><span class="hs-identifier hs-var">mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-427"></span><span>    </span><span id="local-6989586621681187872"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187872"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-428"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681187871"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681187871"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187872"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-429"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681187870"><span class="annot"><span class="annottext">fe_nm :: CLabelString
</span><a href="#local-6989586621681187870"><span class="hs-identifier hs-var hs-var">fe_nm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; CLabelString
</span><a href="GHC.Data.FastString.html#mkFastString"><span class="hs-identifier hs-var">mkFastString</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; CLabelString) -&gt; String -&gt; CLabelString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String
</span><a href="GHC.Utils.Encoding.html#zEncodeString"><span class="hs-identifier hs-var">zEncodeString</span></a></span><span>
</span><span id="line-430"></span><span>            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module -&gt; String
</span><a href="GHC.Unit.Module.html#moduleStableString"><span class="hs-identifier hs-var">moduleStableString</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681187873"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;$&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Id -&gt; String
</span><a href="GHC.HsToCore.Foreign.Decl.html#toCName"><span class="hs-identifier hs-var">toCName</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187872"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187876"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-431"></span><span>        </span><span class="hs-comment">-- Construct the label based on the passed id, don't use names</span><span>
</span><span id="line-432"></span><span>        </span><span class="hs-comment">-- depending on Unique. See #13807 and Note [Unique Determinism].</span><span>
</span><span id="line-433"></span><span>    </span><span id="local-6989586621681187865"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187865"><span class="hs-identifier hs-var">cback</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; DsM Id
</span><a href="GHC.HsToCore.Monad.html#newSysLocalDs"><span class="hs-identifier hs-var">newSysLocalDs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187863"><span class="hs-identifier hs-var">arg_mult</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187862"><span class="hs-identifier hs-var">arg_ty</span></a></span><span>
</span><span id="line-434"></span><span>    </span><span id="local-6989586621681187861"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187861"><span class="hs-identifier hs-var">newStablePtrId</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; DsM Id
</span><a href="GHC.HsToCore.Monad.html#dsLookupGlobalId"><span class="hs-identifier hs-var">dsLookupGlobalId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="GHC.Builtin.Names.html#newStablePtrName"><span class="hs-identifier hs-var">newStablePtrName</span></a></span><span>
</span><span id="line-435"></span><span>    </span><span id="local-6989586621681187858"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187858"><span class="hs-identifier hs-var">stable_ptr_tycon</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; DsM TyCon
</span><a href="GHC.HsToCore.Monad.html#dsLookupTyCon"><span class="hs-identifier hs-var">dsLookupTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="GHC.Builtin.Names.html#stablePtrTyConName"><span class="hs-identifier hs-var">stablePtrTyConName</span></a></span><span>
</span><span id="line-436"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-437"></span><span>        </span><span id="local-6989586621681187855"><span class="annot"><span class="annottext">stable_ptr_ty :: Type
</span><a href="#local-6989586621681187855"><span class="hs-identifier hs-var hs-var">stable_ptr_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [Type] -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187858"><span class="hs-identifier hs-var">stable_ptr_tycon</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187862"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-438"></span><span>        </span><span id="local-6989586621681187853"><span class="annot"><span class="annottext">export_ty :: Type
</span><a href="#local-6989586621681187853"><span class="hs-identifier hs-var hs-var">export_ty</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTyMany"><span class="hs-identifier hs-var">mkVisFunTyMany</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187855"><span class="hs-identifier hs-var">stable_ptr_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187862"><span class="hs-identifier hs-var">arg_ty</span></a></span><span>
</span><span id="line-439"></span><span>    </span><span id="local-6989586621681187851"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187851"><span class="hs-identifier hs-var">bindIOId</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; DsM Id
</span><a href="GHC.HsToCore.Monad.html#dsLookupGlobalId"><span class="hs-identifier hs-var">dsLookupGlobalId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="GHC.Builtin.Names.html#bindIOName"><span class="hs-identifier hs-var">bindIOName</span></a></span><span>
</span><span id="line-440"></span><span>    </span><span id="local-6989586621681187849"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187849"><span class="hs-identifier hs-var">stbl_value</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; DsM Id
</span><a href="GHC.HsToCore.Monad.html#newSysLocalDs"><span class="hs-identifier hs-var">newSysLocalDs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187855"><span class="hs-identifier hs-var">stable_ptr_ty</span></a></span><span>
</span><span id="line-441"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681187848"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187848"><span class="hs-identifier hs-var">h_code</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187847"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187847"><span class="hs-identifier hs-var">c_code</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187846"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681187846"><span class="hs-identifier hs-var">typestring</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187845"><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187845"><span class="hs-identifier hs-var">args_size</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; Coercion
-&gt; CLabelString
-&gt; CCallConv
-&gt; Bool
-&gt; DsM (SDoc, SDoc, String, Arity)
</span><a href="GHC.HsToCore.Foreign.Decl.html#dsFExport"><span class="hs-identifier hs-var">dsFExport</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187876"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkRepReflCo"><span class="hs-identifier hs-var">mkRepReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187853"><span class="hs-identifier hs-var">export_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187870"><span class="hs-identifier hs-var">fe_nm</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681187874"><span class="hs-identifier hs-var">cconv</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-442"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-443"></span><span>         </span><span class="hs-comment">{-
          The arguments to the external function which will
          create a little bit of (template) code on the fly
          for allowing the (stable pointed) Haskell closure
          to be entered using an external calling convention
          (stdcall, ccall).
         -}</span><span>
</span><span id="line-450"></span><span>        </span><span id="local-6989586621681187843"><span class="annot"><span class="annottext">adj_args :: [CoreExpr]
</span><a href="#local-6989586621681187843"><span class="hs-identifier hs-var hs-var">adj_args</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Integer -&gt; CoreExpr
forall b. Platform -&gt; Integer -&gt; Expr b
</span><a href="GHC.Core.html#mkIntLit"><span class="hs-identifier hs-var">mkIntLit</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187871"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Arity -&gt; Integer
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CCallConv -&gt; Arity
</span><a href="GHC.Types.ForeignCall.html#ccallConvToInt"><span class="hs-identifier hs-var">ccallConvToInt</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681187874"><span class="hs-identifier hs-var">cconv</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-451"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187849"><span class="hs-identifier hs-var">stbl_value</span></a></span><span>
</span><span id="line-452"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Literal -&gt; CoreExpr
forall b. Literal -&gt; Expr b
</span><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-var">Lit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabelString -&gt; Maybe Arity -&gt; FunctionOrData -&gt; Literal
</span><a href="GHC.Types.Literal.html#LitLabel"><span class="hs-identifier hs-var">LitLabel</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187870"><span class="hs-identifier hs-var">fe_nm</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Arity
</span><a href="#local-6989586621681187840"><span class="hs-identifier hs-var">mb_sz_args</span></a></span><span> </span><span class="annot"><span class="annottext">FunctionOrData
</span><a href="GHC.Types.Basic.html#IsFunction"><span class="hs-identifier hs-var">IsFunction</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-453"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Literal -&gt; CoreExpr
forall b. Literal -&gt; Expr b
</span><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-var">Lit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Literal
</span><a href="GHC.Types.Literal.html#mkLitString"><span class="hs-identifier hs-var">mkLitString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681187846"><span class="hs-identifier hs-var">typestring</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-454"></span><span>                        </span><span class="hs-special">]</span><span>
</span><span id="line-455"></span><span>          </span><span class="hs-comment">-- name of external entry point providing these services.</span><span>
</span><span id="line-456"></span><span>          </span><span class="hs-comment">-- (probably in the RTS.)</span><span>
</span><span id="line-457"></span><span>        </span><span id="local-6989586621681187838"><span class="annot"><span class="annottext">adjustor :: CLabelString
</span><a href="#local-6989586621681187838"><span class="hs-identifier hs-var hs-var">adjustor</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; CLabelString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;createAdjustor&quot;</span></span><span>
</span><span id="line-458"></span><span>
</span><span id="line-459"></span><span>          </span><span class="hs-comment">-- Determine the number of bytes of arguments to the stub function,</span><span>
</span><span id="line-460"></span><span>          </span><span class="hs-comment">-- so that we can attach the '@N' suffix to its label if it is a</span><span>
</span><span id="line-461"></span><span>          </span><span class="hs-comment">-- stdcall on Windows.</span><span>
</span><span id="line-462"></span><span>        </span><span id="local-6989586621681187840"><span class="annot"><span class="annottext">mb_sz_args :: Maybe Arity
</span><a href="#local-6989586621681187840"><span class="hs-identifier hs-var hs-var">mb_sz_args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681187874"><span class="hs-identifier hs-var">cconv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-463"></span><span>                        </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#StdCallConv"><span class="hs-identifier hs-var">StdCallConv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Arity -&gt; Maybe Arity
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187845"><span class="hs-identifier hs-var">args_size</span></a></span><span>
</span><span id="line-464"></span><span>                        </span><span class="annot"><span class="annottext">CCallConv
</span><span class="hs-identifier">_</span></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Arity
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-465"></span><span>
</span><span id="line-466"></span><span>    </span><span id="local-6989586621681187837"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187837"><span class="hs-identifier hs-var">ccall_adj</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CLabelString -&gt; [CoreExpr] -&gt; Safety -&gt; Type -&gt; DsM CoreExpr
</span><a href="GHC.HsToCore.Foreign.Call.html#dsCCall"><span class="hs-identifier hs-var">dsCCall</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187838"><span class="hs-identifier hs-var">adjustor</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681187843"><span class="hs-identifier hs-var">adj_args</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="GHC.Types.ForeignCall.html#PlayRisky"><span class="hs-identifier hs-var">PlayRisky</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [Type] -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187834"><span class="hs-identifier hs-var">io_tc</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187833"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-467"></span><span>        </span><span class="hs-comment">-- PlayRisky: the adjustor doesn't allocate in the Haskell heap or do a callback</span><span>
</span><span id="line-468"></span><span>
</span><span id="line-469"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681187832"><span class="annot"><span class="annottext">io_app :: CoreExpr
</span><a href="#local-6989586621681187832"><span class="hs-identifier hs-var hs-var">io_app</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; CoreExpr -&gt; CoreExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187831"><span class="hs-identifier hs-var">tvs</span></a></span><span>                  </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; CoreExpr -&gt; CoreExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-470"></span><span>                 </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreExpr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187865"><span class="hs-identifier hs-var">cback</span></a></span><span>                   </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; CoreExpr -&gt; CoreExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-471"></span><span>                 </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
forall b. Expr b -&gt; [Expr b] -&gt; Expr b
</span><a href="GHC.Core.html#mkApps"><span class="hs-identifier hs-var">mkApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187851"><span class="hs-identifier hs-var">bindIOId</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-472"></span><span>                        </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Type -&gt; CoreExpr
forall b. Type -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187855"><span class="hs-identifier hs-var">stable_ptr_ty</span></a></span><span>
</span><span id="line-473"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type -&gt; CoreExpr
forall b. Type -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187833"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-474"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
forall b. Expr b -&gt; [Expr b] -&gt; Expr b
</span><a href="GHC.Core.html#mkApps"><span class="hs-identifier hs-var">mkApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187861"><span class="hs-identifier hs-var">newStablePtrId</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Type -&gt; CoreExpr
forall b. Type -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187862"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187865"><span class="hs-identifier hs-var">cback</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-475"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreExpr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187849"><span class="hs-identifier hs-var">stbl_value</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187837"><span class="hs-identifier hs-var">ccall_adj</span></a></span><span>
</span><span id="line-476"></span><span>                        </span><span class="hs-special">]</span><span>
</span><span id="line-477"></span><span>
</span><span id="line-478"></span><span>        </span><span id="local-6989586621681187828"><span class="annot"><span class="annottext">fed :: Binding
</span><a href="#local-6989586621681187828"><span class="hs-identifier hs-var hs-var">fed</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187876"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Activation -&gt; Id
</span><a href="GHC.Types.Id.html#setInlineActivation"><span class="hs-operator hs-var">`setInlineActivation`</span></a></span><span> </span><span class="annot"><span class="annottext">Activation
</span><a href="GHC.Types.Basic.html#NeverActive"><span class="hs-identifier hs-var">NeverActive</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Coercion -&gt; CoreExpr
forall b. Expr b -&gt; Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681187832"><span class="hs-identifier hs-var">io_app</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681187875"><span class="hs-identifier hs-var">co0</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-479"></span><span>               </span><span class="hs-comment">-- Never inline the f.e.d. function, because the litlit</span><span>
</span><span id="line-480"></span><span>               </span><span class="hs-comment">-- might not be in scope in other modules.</span><span>
</span><span id="line-481"></span><span>
</span><span id="line-482"></span><span>    </span><span class="annot"><span class="annottext">([Binding], SDoc, SDoc) -&gt; DsM ([Binding], SDoc, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><span class="annottext">Binding
</span><a href="#local-6989586621681187828"><span class="hs-identifier hs-var">fed</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187848"><span class="hs-identifier hs-var">h_code</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187847"><span class="hs-identifier hs-var">c_code</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-483"></span><span>
</span><span id="line-484"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-485"></span><span>  </span><span id="local-6989586621681187825"><span class="annot"><span class="annottext">ty :: Type
</span><a href="#local-6989586621681187825"><span class="hs-identifier hs-var hs-var">ty</span></a></span></span><span>                       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type
</span><a href="GHC.Core.Coercion.html#coercionLKind"><span class="hs-identifier hs-var">coercionLKind</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681187875"><span class="hs-identifier hs-var">co0</span></a></span><span>
</span><span id="line-486"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621681187831"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187831"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681187824"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187824"><span class="hs-identifier hs-var">sans_foralls</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([Id], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitForAllTys"><span class="hs-identifier hs-var">tcSplitForAllTys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187825"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-487"></span><span>  </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span id="local-6989586621681187863"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187863"><span class="hs-identifier hs-var">arg_mult</span></a></span></span><span> </span><span id="local-6989586621681187862"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187862"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187822"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187822"><span class="hs-identifier hs-var">fn_res_ty</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([Scaled Type], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitFunTys"><span class="hs-identifier hs-var">tcSplitFunTys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187824"><span class="hs-identifier hs-var">sans_foralls</span></a></span><span>
</span><span id="line-488"></span><span>  </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681187834"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187834"><span class="hs-identifier hs-var">io_tc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187833"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187833"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (TyCon, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitIOType_maybe"><span class="hs-identifier hs-var">tcSplitIOType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187822"><span class="hs-identifier hs-var">fn_res_ty</span></a></span><span>
</span><span id="line-489"></span><span>        </span><span class="hs-comment">-- Must have an IO type; hence Just</span><span>
</span><span id="line-490"></span><span>
</span><span id="line-491"></span><span>
</span><span id="line-492"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#toCName"><span class="hs-identifier hs-type">toCName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-493"></span><span id="toCName"><span class="annot"><span class="annottext">toCName :: DynFlags -&gt; Id -&gt; String
</span><a href="GHC.HsToCore.Foreign.Decl.html#toCName"><span class="hs-identifier hs-var hs-var">toCName</span></a></span></span><span> </span><span id="local-6989586621681187821"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187821"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681187820"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187820"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; SDoc -&gt; String
</span><a href="GHC.Utils.Outputable.html#showSDoc"><span class="hs-identifier hs-var">showSDoc</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187821"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CodeStyle -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#pprCode"><span class="hs-identifier hs-var">pprCode</span></a></span><span> </span><span class="annot"><span class="annottext">CodeStyle
</span><a href="GHC.Utils.Outputable.html#CStyle"><span class="hs-identifier hs-var">CStyle</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187820"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-494"></span><span>
</span><span id="line-495"></span><span class="hs-comment">{-
*

\subsection{Generating @foreign export@ stubs}

*

For each @foreign export@ function, a C stub function is generated.
The C stub constructs the application of the exported Haskell function
using the hugs/ghc rts invocation API.
-}</span><span>
</span><span id="line-506"></span><span>
</span><span id="line-507"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#mkFExportCBits"><span class="hs-identifier hs-type">mkFExportCBits</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-508"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastString"><span class="hs-identifier hs-type">FastString</span></a></span><span>
</span><span id="line-509"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>      </span><span class="hs-comment">-- Just==static, Nothing==dynamic</span><span>
</span><span id="line-510"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-511"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-512"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>          </span><span class="hs-comment">-- True &lt;=&gt; returns an IO type</span><span>
</span><span id="line-513"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-type">CCallConv</span></a></span><span>
</span><span id="line-514"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-515"></span><span>                   </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-516"></span><span>                   </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span>      </span><span class="hs-comment">-- the argument reps</span><span>
</span><span id="line-517"></span><span>                   </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>          </span><span class="hs-comment">-- total size of arguments</span><span>
</span><span id="line-518"></span><span>                  </span><span class="hs-special">)</span><span>
</span><span id="line-519"></span><span id="mkFExportCBits"><span class="annot"><span class="annottext">mkFExportCBits :: DynFlags
-&gt; CLabelString
-&gt; Maybe Id
-&gt; [Type]
-&gt; Type
-&gt; Bool
-&gt; CCallConv
-&gt; (SDoc, SDoc, String, Arity)
</span><a href="GHC.HsToCore.Foreign.Decl.html#mkFExportCBits"><span class="hs-identifier hs-var hs-var">mkFExportCBits</span></a></span></span><span> </span><span id="local-6989586621681187814"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187814"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681187813"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187813"><span class="hs-identifier hs-var">c_nm</span></a></span></span><span> </span><span id="local-6989586621681187812"><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681187812"><span class="hs-identifier hs-var">maybe_target</span></a></span></span><span> </span><span id="local-6989586621681187811"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681187811"><span class="hs-identifier hs-var">arg_htys</span></a></span></span><span> </span><span id="local-6989586621681187810"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187810"><span class="hs-identifier hs-var">res_hty</span></a></span></span><span> </span><span id="local-6989586621681187809"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187809"><span class="hs-identifier hs-var">is_IO_res_ty</span></a></span></span><span> </span><span id="local-6989586621681187808"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681187808"><span class="hs-identifier hs-var">cc</span></a></span></span><span>
</span><span id="line-520"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187807"><span class="hs-identifier hs-var">header_bits</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187806"><span class="hs-identifier hs-var">c_bits</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681187805"><span class="hs-identifier hs-var">type_string</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-521"></span><span>    </span><span class="annot"><span class="annottext">[Arity] -&gt; Arity
forall (t :: * -&gt; *) a. (Foldable t, Num a) =&gt; t a -&gt; a
</span><a href="../../base/src/Data.Foldable.html#sum"><span class="hs-identifier hs-var">sum</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Width -&gt; Arity
</span><a href="GHC.Cmm.Type.html#widthInBytes"><span class="hs-identifier hs-var">widthInBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmType -&gt; Width
</span><a href="GHC.Cmm.Type.html#typeWidth"><span class="hs-identifier hs-var">typeWidth</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681187804"><span class="hs-identifier hs-var">rep</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">SDoc
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681187804"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681187804"><span class="hs-identifier hs-var">rep</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187803"><span class="hs-identifier hs-var">aug_arg_info</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- all the args</span><span>
</span><span id="line-522"></span><span>         </span><span class="hs-comment">-- NB. the calculation here isn't strictly speaking correct.</span><span>
</span><span id="line-523"></span><span>         </span><span class="hs-comment">-- We have a primitive Haskell type (eg. Int#, Double#), and</span><span>
</span><span id="line-524"></span><span>         </span><span class="hs-comment">-- we want to know the size, when passed on the C stack, of</span><span>
</span><span id="line-525"></span><span>         </span><span class="hs-comment">-- the associated C type (eg. HsInt, HsDouble).  We don't have</span><span>
</span><span id="line-526"></span><span>         </span><span class="hs-comment">-- this information to hand, but we know what GHC's conventions</span><span>
</span><span id="line-527"></span><span>         </span><span class="hs-comment">-- are for passing around the primitive Haskell types, so we</span><span>
</span><span id="line-528"></span><span>         </span><span class="hs-comment">-- use that instead.  I hope the two coincide --SDM</span><span>
</span><span id="line-529"></span><span>    </span><span class="hs-special">)</span><span>
</span><span id="line-530"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-531"></span><span>  </span><span id="local-6989586621681187802"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681187802"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187814"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-532"></span><span>
</span><span id="line-533"></span><span>  </span><span class="hs-comment">-- list the arguments to the C function</span><span>
</span><span id="line-534"></span><span>  </span><span class="annot"><a href="#local-6989586621681187801"><span class="hs-identifier hs-type">arg_info</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span>           </span><span class="hs-comment">-- arg name</span><span>
</span><span id="line-535"></span><span>                </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span>           </span><span class="hs-comment">-- C type</span><span>
</span><span id="line-536"></span><span>                </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span>           </span><span class="hs-comment">-- Haskell type</span><span>
</span><span id="line-537"></span><span>                </span><span class="annot"><a href="GHC.Cmm.Type.html#CmmType"><span class="hs-identifier hs-type">CmmType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>       </span><span class="hs-comment">-- the CmmType</span><span>
</span><span id="line-538"></span><span>  </span><span id="local-6989586621681187801"><span class="annot"><span class="annottext">arg_info :: [(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187801"><span class="hs-identifier hs-var hs-var">arg_info</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681187800"><span class="annot"><span class="annottext">stg_type :: SDoc
</span><a href="#local-6989586621681187800"><span class="hs-identifier hs-var hs-var">stg_type</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
</span><a href="GHC.HsToCore.Foreign.Decl.html#showStgType"><span class="hs-identifier hs-var">showStgType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187798"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-539"></span><span>                    </span><span id="local-6989586621681187797"><span class="annot"><span class="annottext">cmm_type :: CmmType
</span><a href="#local-6989586621681187797"><span class="hs-identifier hs-var hs-var">cmm_type</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Type -&gt; CmmType
</span><a href="GHC.Cmm.Utils.html#typeCmmType"><span class="hs-identifier hs-var">typeCmmType</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187802"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="GHC.HsToCore.Foreign.Decl.html#getPrimTyOf"><span class="hs-identifier hs-var">getPrimTyOf</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187798"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-540"></span><span>                    </span><span id="local-6989586621681187796"><span class="annot"><span class="annottext">stack_type :: SDoc
</span><a href="#local-6989586621681187796"><span class="hs-identifier hs-var hs-var">stack_type</span></a></span></span><span>
</span><span id="line-541"></span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="#local-6989586621681187795"><span class="hs-identifier hs-var">int_promote</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; TyCon
</span><a href="GHC.HsToCore.Foreign.Decl.html#typeTyCon"><span class="hs-identifier hs-var">typeTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187798"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-542"></span><span>                        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;HsWord&quot;</span></span><span>
</span><span id="line-543"></span><span>                        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187800"><span class="hs-identifier hs-var">stg_type</span></a></span><span>
</span><span id="line-544"></span><span>                </span><span class="hs-keyword">in</span><span>
</span><span id="line-545"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Arity -&gt; SDoc -&gt; SDoc -&gt; SDoc
</span><a href="#local-6989586621681187793"><span class="hs-identifier hs-var">arg_cname</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187792"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187800"><span class="hs-identifier hs-var">stg_type</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187796"><span class="hs-identifier hs-var">stack_type</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-546"></span><span>                 </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187800"><span class="hs-identifier hs-var">stg_type</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-547"></span><span>                 </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187798"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-548"></span><span>                 </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681187797"><span class="hs-identifier hs-var">cmm_type</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-549"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681187798"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187798"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681187792"><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187792"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Arity] -&gt; [(Type, Arity)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681187811"><span class="hs-identifier hs-var">arg_htys</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">1</span></span><span class="hs-glyph">::</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">..</span><span class="hs-special">]</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-550"></span><span>
</span><span id="line-551"></span><span>  </span><span id="local-6989586621681187795"><span class="annot"><span class="annottext">int_promote :: TyCon -&gt; Bool
</span><a href="#local-6989586621681187795"><span class="hs-identifier hs-var hs-var">int_promote</span></a></span></span><span> </span><span id="local-6989586621681187791"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187791"><span class="hs-identifier hs-var">ty_con</span></a></span></span><span>
</span><span id="line-552"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187791"><span class="hs-identifier hs-var">ty_con</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#int8TyConKey"><span class="hs-identifier hs-var">int8TyConKey</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-553"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187791"><span class="hs-identifier hs-var">ty_con</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#int16TyConKey"><span class="hs-identifier hs-var">int16TyConKey</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-554"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187791"><span class="hs-identifier hs-var">ty_con</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#int32TyConKey"><span class="hs-identifier hs-var">int32TyConKey</span></a></span><span>
</span><span id="line-555"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Arity
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformWordSizeInBytes"><span class="hs-identifier hs-var">platformWordSizeInBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187802"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Arity -&gt; Arity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">4</span></span><span>
</span><span id="line-556"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-557"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187791"><span class="hs-identifier hs-var">ty_con</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#word8TyConKey"><span class="hs-identifier hs-var">word8TyConKey</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-558"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187791"><span class="hs-identifier hs-var">ty_con</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#word16TyConKey"><span class="hs-identifier hs-var">word16TyConKey</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-559"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187791"><span class="hs-identifier hs-var">ty_con</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#word32TyConKey"><span class="hs-identifier hs-var">word32TyConKey</span></a></span><span>
</span><span id="line-560"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Arity
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformWordSizeInBytes"><span class="hs-identifier hs-var">platformWordSizeInBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187802"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Arity -&gt; Arity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">4</span></span><span>
</span><span id="line-561"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-562"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-563"></span><span>
</span><span id="line-564"></span><span>
</span><span id="line-565"></span><span>  </span><span id="local-6989586621681187793"><span class="annot"><span class="annottext">arg_cname :: Arity -&gt; SDoc -&gt; SDoc -&gt; SDoc
</span><a href="#local-6989586621681187793"><span class="hs-identifier hs-var hs-var">arg_cname</span></a></span></span><span> </span><span id="local-6989586621681187781"><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187781"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681187780"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187780"><span class="hs-identifier hs-var">stg_ty</span></a></span></span><span> </span><span id="local-6989586621681187779"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187779"><span class="hs-identifier hs-var">stack_ty</span></a></span></span><span>
</span><span id="line-566"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187778"><span class="hs-identifier hs-var">libffi</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187780"><span class="hs-identifier hs-var">stg_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'*'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span>
</span><span id="line-567"></span><span>                      </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187779"><span class="hs-identifier hs-var">stack_ty</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'*'</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span>
</span><span id="line-568"></span><span>                      </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;args&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#brackets"><span class="hs-identifier hs-var">brackets</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Arity -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187781"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Arity -&gt; Arity -&gt; Arity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-569"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'a'</span></span><span class="annot"><span class="annottext">Char -&gt; String -&gt; String
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">Arity -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187781"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-570"></span><span>
</span><span id="line-571"></span><span>  </span><span class="hs-comment">-- generate a libffi-style stub if this is a &quot;wrapper&quot; and libffi is enabled</span><span>
</span><span id="line-572"></span><span>  </span><span id="local-6989586621681187778"><span class="annot"><span class="annottext">libffi :: Bool
</span><a href="#local-6989586621681187778"><span class="hs-identifier hs-var hs-var">libffi</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PlatformMisc -&gt; Bool
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformMisc_libFFI"><span class="hs-identifier hs-var hs-var">platformMisc_libFFI</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; PlatformMisc
</span><a href="GHC.Driver.Session.html#platformMisc"><span class="hs-identifier hs-var hs-var">platformMisc</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681187814"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Maybe Id -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isNothing"><span class="hs-identifier hs-var">isNothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681187812"><span class="hs-identifier hs-var">maybe_target</span></a></span><span>
</span><span id="line-573"></span><span>
</span><span id="line-574"></span><span>  </span><span id="local-6989586621681187805"><span class="annot"><span class="annottext">type_string :: String
</span><a href="#local-6989586621681187805"><span class="hs-identifier hs-var hs-var">type_string</span></a></span></span><span>
</span><span id="line-575"></span><span>      </span><span class="hs-comment">-- libffi needs to know the result type too:</span><span>
</span><span id="line-576"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187778"><span class="hs-identifier hs-var">libffi</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Type -&gt; Char
</span><a href="GHC.HsToCore.Foreign.Decl.html#primTyDescChar"><span class="hs-identifier hs-var">primTyDescChar</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187802"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187810"><span class="hs-identifier hs-var">res_hty</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; String -&gt; String
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681187771"><span class="hs-identifier hs-var">arg_type_string</span></a></span><span>
</span><span id="line-577"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681187771"><span class="hs-identifier hs-var">arg_type_string</span></a></span><span>
</span><span id="line-578"></span><span>
</span><span id="line-579"></span><span>  </span><span id="local-6989586621681187771"><span class="annot"><span class="annottext">arg_type_string :: String
</span><a href="#local-6989586621681187771"><span class="hs-identifier hs-var hs-var">arg_type_string</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Platform -&gt; Type -&gt; Char
</span><a href="GHC.HsToCore.Foreign.Decl.html#primTyDescChar"><span class="hs-identifier hs-var">primTyDescChar</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187802"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187770"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">SDoc
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681187770"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187770"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CmmType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187801"><span class="hs-identifier hs-var">arg_info</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-580"></span><span>                </span><span class="hs-comment">-- just the real args</span><span>
</span><span id="line-581"></span><span>
</span><span id="line-582"></span><span>  </span><span class="hs-comment">-- add some auxiliary args; the stable ptr in the wrapper case, and</span><span>
</span><span id="line-583"></span><span>  </span><span class="hs-comment">-- a slot for the dummy return address in the wrapper + ccall case</span><span>
</span><span id="line-584"></span><span>  </span><span id="local-6989586621681187803"><span class="annot"><span class="annottext">aug_arg_info :: [(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187803"><span class="hs-identifier hs-var hs-var">aug_arg_info</span></a></span></span><span>
</span><span id="line-585"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Maybe Id -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isNothing"><span class="hs-identifier hs-var">isNothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681187812"><span class="hs-identifier hs-var">maybe_target</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SDoc, SDoc, Type, CmmType)
</span><a href="#local-6989586621681187769"><span class="hs-identifier hs-var">stable_ptr_arg</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc, SDoc, Type, CmmType)
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">Platform
-&gt; CCallConv
-&gt; [(SDoc, SDoc, Type, CmmType)]
-&gt; [(SDoc, SDoc, Type, CmmType)]
</span><a href="GHC.HsToCore.Foreign.Decl.html#insertRetAddr"><span class="hs-identifier hs-var">insertRetAddr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187802"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681187808"><span class="hs-identifier hs-var">cc</span></a></span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187801"><span class="hs-identifier hs-var">arg_info</span></a></span><span>
</span><span id="line-586"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187801"><span class="hs-identifier hs-var">arg_info</span></a></span><span>
</span><span id="line-587"></span><span>
</span><span id="line-588"></span><span>  </span><span id="local-6989586621681187769"><span class="annot"><span class="annottext">stable_ptr_arg :: (SDoc, SDoc, Type, CmmType)
</span><a href="#local-6989586621681187769"><span class="hs-identifier hs-var hs-var">stable_ptr_arg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-589"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;the_stableptr&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;StgStablePtr&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
forall a. HasCallStack =&gt; a
</span><a href="../../base/src/GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-590"></span><span>         </span><span class="annot"><span class="annottext">Platform -&gt; Type -&gt; CmmType
</span><a href="GHC.Cmm.Utils.html#typeCmmType"><span class="hs-identifier hs-var">typeCmmType</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187802"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="GHC.Builtin.Types.Prim.html#mkStablePtrPrimTy"><span class="hs-identifier hs-var">mkStablePtrPrimTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#alphaTy"><span class="hs-identifier hs-var">alphaTy</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-591"></span><span>
</span><span id="line-592"></span><span>  </span><span class="hs-comment">-- stuff to do with the return type of the C function</span><span>
</span><span id="line-593"></span><span>  </span><span id="local-6989586621681187764"><span class="annot"><span class="annottext">res_hty_is_unit :: Bool
</span><a href="#local-6989586621681187764"><span class="hs-identifier hs-var hs-var">res_hty_is_unit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187810"><span class="hs-identifier hs-var">res_hty</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Bool
</span><a href="GHC.Core.Type.html#eqType"><span class="hs-operator hs-var">`eqType`</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#unitTy"><span class="hs-identifier hs-var">unitTy</span></a></span><span>     </span><span class="hs-comment">-- Look through any newtypes</span><span>
</span><span id="line-594"></span><span>
</span><span id="line-595"></span><span>  </span><span id="local-6989586621681187763"><span class="annot"><span class="annottext">cResType :: SDoc
</span><a href="#local-6989586621681187763"><span class="hs-identifier hs-var hs-var">cResType</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187764"><span class="hs-identifier hs-var">res_hty_is_unit</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;void&quot;</span></span><span>
</span><span id="line-596"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
</span><a href="GHC.HsToCore.Foreign.Decl.html#showStgType"><span class="hs-identifier hs-var">showStgType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187810"><span class="hs-identifier hs-var">res_hty</span></a></span><span>
</span><span id="line-597"></span><span>
</span><span id="line-598"></span><span>  </span><span class="hs-comment">-- when the return type is integral and word-sized or smaller, it</span><span>
</span><span id="line-599"></span><span>  </span><span class="hs-comment">-- must be assigned as type ffi_arg (#3516).  To see what type</span><span>
</span><span id="line-600"></span><span>  </span><span class="hs-comment">-- libffi is expecting here, take a look in its own testsuite, e.g.</span><span>
</span><span id="line-601"></span><span>  </span><span class="hs-comment">-- libffi/testsuite/libffi.call/cls_align_ulonglong.c</span><span>
</span><span id="line-602"></span><span>  </span><span id="local-6989586621681187762"><span class="annot"><span class="annottext">ffi_cResType :: SDoc
</span><a href="#local-6989586621681187762"><span class="hs-identifier hs-var hs-var">ffi_cResType</span></a></span></span><span>
</span><span id="line-603"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187761"><span class="hs-identifier hs-var">is_ffi_arg_type</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ffi_arg&quot;</span></span><span>
</span><span id="line-604"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187763"><span class="hs-identifier hs-var">cResType</span></a></span><span>
</span><span id="line-605"></span><span>     </span><span class="hs-keyword">where</span><span>
</span><span id="line-606"></span><span>       </span><span id="local-6989586621681187760"><span class="annot"><span class="annottext">res_ty_key :: Unique
</span><a href="#local-6989586621681187760"><span class="hs-identifier hs-var hs-var">res_ty_key</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Unique
forall a. Uniquable a =&gt; a -&gt; Unique
</span><a href="GHC.Types.Unique.html#getUnique"><span class="hs-identifier hs-var">getUnique</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Name
forall a. NamedThing a =&gt; a -&gt; Name
</span><a href="GHC.Types.Name.html#getName"><span class="hs-identifier hs-var">getName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; TyCon
</span><a href="GHC.HsToCore.Foreign.Decl.html#typeTyCon"><span class="hs-identifier hs-var">typeTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187810"><span class="hs-identifier hs-var">res_hty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-607"></span><span>       </span><span id="local-6989586621681187761"><span class="annot"><span class="annottext">is_ffi_arg_type :: Bool
</span><a href="#local-6989586621681187761"><span class="hs-identifier hs-var hs-var">is_ffi_arg_type</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681187760"><span class="hs-identifier hs-var">res_ty_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; [Unique] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#notElem"><span class="hs-operator hs-var">`notElem`</span></a></span><span>
</span><span id="line-608"></span><span>              </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#floatTyConKey"><span class="hs-identifier hs-var">floatTyConKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#doubleTyConKey"><span class="hs-identifier hs-var">doubleTyConKey</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-609"></span><span>               </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#int64TyConKey"><span class="hs-identifier hs-var">int64TyConKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#word64TyConKey"><span class="hs-identifier hs-var">word64TyConKey</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-610"></span><span>
</span><span id="line-611"></span><span>  </span><span class="hs-comment">-- Now we can cook up the prototype for the exported function.</span><span>
</span><span id="line-612"></span><span>  </span><span id="local-6989586621681187752"><span class="annot"><span class="annottext">pprCconv :: SDoc
</span><a href="#local-6989586621681187752"><span class="hs-identifier hs-var hs-var">pprCconv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CCallConv -&gt; SDoc
</span><a href="GHC.Types.ForeignCall.html#ccallConvAttribute"><span class="hs-identifier hs-var">ccallConvAttribute</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681187808"><span class="hs-identifier hs-var">cc</span></a></span><span>
</span><span id="line-613"></span><span>
</span><span id="line-614"></span><span>  </span><span id="local-6989586621681187807"><span class="annot"><span class="annottext">header_bits :: SDoc
</span><a href="#local-6989586621681187807"><span class="hs-identifier hs-var hs-var">header_bits</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;extern&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187751"><span class="hs-identifier hs-var">fun_proto</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#semi"><span class="hs-identifier hs-var">semi</span></a></span><span>
</span><span id="line-615"></span><span>
</span><span id="line-616"></span><span>  </span><span id="local-6989586621681187750"><span class="annot"><span class="annottext">fun_args :: SDoc
</span><a href="#local-6989586621681187750"><span class="hs-identifier hs-var hs-var">fun_args</span></a></span></span><span>
</span><span id="line-617"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187803"><span class="hs-identifier hs-var">aug_arg_info</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;void&quot;</span></span><span>
</span><span id="line-618"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; [SDoc] -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; [SDoc] -&gt; [SDoc]
</span><a href="GHC.Utils.Outputable.html#punctuate"><span class="hs-identifier hs-var">punctuate</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span>
</span><span id="line-619"></span><span>                               </span><span class="annot"><span class="annottext">([SDoc] -&gt; [SDoc]) -&gt; [SDoc] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">((SDoc, SDoc, Type, CmmType) -&gt; SDoc)
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621681187749"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187749"><span class="hs-identifier hs-var">nm</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681187748"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187748"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CmmType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187748"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187749"><span class="hs-identifier hs-var">nm</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187803"><span class="hs-identifier hs-var">aug_arg_info</span></a></span><span>
</span><span id="line-620"></span><span>
</span><span id="line-621"></span><span>  </span><span id="local-6989586621681187751"><span class="annot"><span class="annottext">fun_proto :: SDoc
</span><a href="#local-6989586621681187751"><span class="hs-identifier hs-var hs-var">fun_proto</span></a></span></span><span>
</span><span id="line-622"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187778"><span class="hs-identifier hs-var">libffi</span></a></span><span>
</span><span id="line-623"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;void&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ftext"><span class="hs-identifier hs-var">ftext</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187813"><span class="hs-identifier hs-var">c_nm</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span>
</span><span id="line-624"></span><span>          </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;void *cif STG_UNUSED, void* resp, void** args, void* the_stableptr&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-625"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-626"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187763"><span class="hs-identifier hs-var">cResType</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187752"><span class="hs-identifier hs-var">pprCconv</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ftext"><span class="hs-identifier hs-var">ftext</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187813"><span class="hs-identifier hs-var">c_nm</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187750"><span class="hs-identifier hs-var">fun_args</span></a></span><span>
</span><span id="line-627"></span><span>
</span><span id="line-628"></span><span>  </span><span class="hs-comment">-- the target which will form the root of what we ask rts_evalIO to run</span><span>
</span><span id="line-629"></span><span>  </span><span id="local-6989586621681187747"><span class="annot"><span class="annottext">the_cfun :: SDoc
</span><a href="#local-6989586621681187747"><span class="hs-identifier hs-var hs-var">the_cfun</span></a></span></span><span>
</span><span id="line-630"></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681187812"><span class="hs-identifier hs-var">maybe_target</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-631"></span><span>          </span><span class="annot"><span class="annottext">Maybe Id
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;(StgClosure*)deRefStablePtr(the_stableptr)&quot;</span></span><span>
</span><span id="line-632"></span><span>          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681187746"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187746"><span class="hs-identifier hs-var">hs_fn</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'&amp;'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187746"><span class="hs-identifier hs-var">hs_fn</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;_closure&quot;</span></span><span>
</span><span id="line-633"></span><span>
</span><span id="line-634"></span><span>  </span><span id="local-6989586621681187745"><span class="annot"><span class="annottext">cap :: SDoc
</span><a href="#local-6989586621681187745"><span class="hs-identifier hs-var hs-var">cap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cap&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span>
</span><span id="line-635"></span><span>
</span><span id="line-636"></span><span>  </span><span class="hs-comment">-- the expression we give to rts_evalIO</span><span>
</span><span id="line-637"></span><span>  </span><span id="local-6989586621681187744"><span class="annot"><span class="annottext">expr_to_run :: SDoc
</span><a href="#local-6989586621681187744"><span class="hs-identifier hs-var hs-var">expr_to_run</span></a></span></span><span>
</span><span id="line-638"></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; (SDoc, SDoc, Type, CmmType) -&gt; SDoc)
-&gt; SDoc -&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; SDoc
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; (SDoc, SDoc, Type, CmmType) -&gt; SDoc
forall {b} {d}. SDoc -&gt; (SDoc, b, Type, d) -&gt; SDoc
</span><a href="#local-6989586621681187742"><span class="hs-identifier hs-var">appArg</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187747"><span class="hs-identifier hs-var">the_cfun</span></a></span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187801"><span class="hs-identifier hs-var">arg_info</span></a></span><span> </span><span class="hs-comment">-- NOT aug_arg_info</span><span>
</span><span id="line-639"></span><span>       </span><span class="hs-keyword">where</span><span>
</span><span id="line-640"></span><span>          </span><span id="local-6989586621681187742"><span class="annot"><span class="annottext">appArg :: SDoc -&gt; (SDoc, b, Type, d) -&gt; SDoc
</span><a href="#local-6989586621681187742"><span class="hs-identifier hs-var hs-var">appArg</span></a></span></span><span> </span><span id="local-6989586621681187741"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187741"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681187740"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187740"><span class="hs-identifier hs-var">arg_cname</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">b
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187739"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187739"><span class="hs-identifier hs-var">arg_hty</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">d
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-641"></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rts_apply&quot;</span></span><span>
</span><span id="line-642"></span><span>               </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187745"><span class="hs-identifier hs-var">cap</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187741"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
</span><a href="GHC.HsToCore.Foreign.Decl.html#mkHObj"><span class="hs-identifier hs-var">mkHObj</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187739"><span class="hs-identifier hs-var">arg_hty</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187745"><span class="hs-identifier hs-var">cap</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187740"><span class="hs-identifier hs-var">arg_cname</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-643"></span><span>
</span><span id="line-644"></span><span>  </span><span class="hs-comment">-- various other bits for inside the fn</span><span>
</span><span id="line-645"></span><span>  </span><span id="local-6989586621681187737"><span class="annot"><span class="annottext">declareResult :: SDoc
</span><a href="#local-6989586621681187737"><span class="hs-identifier hs-var hs-var">declareResult</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;HaskellObj ret;&quot;</span></span><span>
</span><span id="line-646"></span><span>  </span><span id="local-6989586621681187736"><span class="annot"><span class="annottext">declareCResult :: SDoc
</span><a href="#local-6989586621681187736"><span class="hs-identifier hs-var hs-var">declareCResult</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187764"><span class="hs-identifier hs-var">res_hty_is_unit</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-647"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187763"><span class="hs-identifier hs-var">cResType</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cret;&quot;</span></span><span>
</span><span id="line-648"></span><span>
</span><span id="line-649"></span><span>  </span><span id="local-6989586621681187735"><span class="annot"><span class="annottext">assignCResult :: SDoc
</span><a href="#local-6989586621681187735"><span class="hs-identifier hs-var hs-var">assignCResult</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187764"><span class="hs-identifier hs-var">res_hty_is_unit</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-650"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>       </span><span class="hs-glyph">=</span><span>
</span><span id="line-651"></span><span>                        </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cret=&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
</span><a href="GHC.HsToCore.Foreign.Decl.html#unpackHObj"><span class="hs-identifier hs-var">unpackHObj</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187810"><span class="hs-identifier hs-var">res_hty</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ret&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#semi"><span class="hs-identifier hs-var">semi</span></a></span><span>
</span><span id="line-652"></span><span>
</span><span id="line-653"></span><span>  </span><span class="hs-comment">-- an extern decl for the fn being called</span><span>
</span><span id="line-654"></span><span>  </span><span id="local-6989586621681187733"><span class="annot"><span class="annottext">extern_decl :: SDoc
</span><a href="#local-6989586621681187733"><span class="hs-identifier hs-var hs-var">extern_decl</span></a></span></span><span>
</span><span id="line-655"></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681187812"><span class="hs-identifier hs-var">maybe_target</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-656"></span><span>          </span><span class="annot"><span class="annottext">Maybe Id
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-657"></span><span>          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681187732"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187732"><span class="hs-identifier hs-var">hs_fn</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;extern StgClosure &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187732"><span class="hs-identifier hs-var">hs_fn</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;_closure&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#semi"><span class="hs-identifier hs-var">semi</span></a></span><span>
</span><span id="line-658"></span><span>
</span><span id="line-659"></span><span>
</span><span id="line-660"></span><span>  </span><span class="hs-comment">-- finally, the whole darn thing</span><span>
</span><span id="line-661"></span><span>  </span><span id="local-6989586621681187806"><span class="annot"><span class="annottext">c_bits :: SDoc
</span><a href="#local-6989586621681187806"><span class="hs-identifier hs-var hs-var">c_bits</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-662"></span><span>    </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#space"><span class="hs-identifier hs-var">space</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-663"></span><span>    </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187733"><span class="hs-identifier hs-var">extern_decl</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-664"></span><span>    </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187751"><span class="hs-identifier hs-var">fun_proto</span></a></span><span>  </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-665"></span><span>    </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span>
</span><span id="line-666"></span><span>     </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#lbrace"><span class="hs-identifier hs-var">lbrace</span></a></span><span>
</span><span id="line-667"></span><span>     </span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Capability *cap;&quot;</span></span><span>
</span><span id="line-668"></span><span>     </span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187737"><span class="hs-identifier hs-var">declareResult</span></a></span><span>
</span><span id="line-669"></span><span>     </span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187736"><span class="hs-identifier hs-var">declareCResult</span></a></span><span>
</span><span id="line-670"></span><span>     </span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cap = rts_lock();&quot;</span></span><span>
</span><span id="line-671"></span><span>          </span><span class="hs-comment">-- create the application + perform it.</span><span>
</span><span id="line-672"></span><span>     </span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rts_evalIO&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-673"></span><span>                </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'&amp;'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187745"><span class="hs-identifier hs-var">cap</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span>
</span><span id="line-674"></span><span>                </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rts_apply&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-675"></span><span>                    </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187745"><span class="hs-identifier hs-var">cap</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span>
</span><span id="line-676"></span><span>                    </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;(HaskellObj)&quot;</span></span><span>
</span><span id="line-677"></span><span>                 </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PtrString -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ptext"><span class="hs-identifier hs-var">ptext</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187809"><span class="hs-identifier hs-var">is_IO_res_ty</span></a></span><span>
</span><span id="line-678"></span><span>                                </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; PtrString
</span><a href="GHC.Data.FastString.html#sLit"><span class="hs-identifier hs-var">sLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;runIO_closure&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-679"></span><span>                                </span><span class="hs-keyword">else</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; PtrString
</span><a href="GHC.Data.FastString.html#sLit"><span class="hs-identifier hs-var">sLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;runNonIO_closure&quot;</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-680"></span><span>                 </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span>
</span><span id="line-681"></span><span>                 </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187744"><span class="hs-identifier hs-var">expr_to_run</span></a></span><span>
</span><span id="line-682"></span><span>                </span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span>
</span><span id="line-683"></span><span>               </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&amp;ret&quot;</span></span><span>
</span><span id="line-684"></span><span>             </span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#semi"><span class="hs-identifier hs-var">semi</span></a></span><span>
</span><span id="line-685"></span><span>     </span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rts_checkSchedStatus&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#doubleQuotes"><span class="hs-identifier hs-var">doubleQuotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabelString -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ftext"><span class="hs-identifier hs-var">ftext</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187813"><span class="hs-identifier hs-var">c_nm</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-686"></span><span>                                                </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cap&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#semi"><span class="hs-identifier hs-var">semi</span></a></span><span>
</span><span id="line-687"></span><span>     </span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187735"><span class="hs-identifier hs-var">assignCResult</span></a></span><span>
</span><span id="line-688"></span><span>     </span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rts_unlock(cap);&quot;</span></span><span>
</span><span id="line-689"></span><span>     </span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppUnless"><span class="hs-identifier hs-var">ppUnless</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187764"><span class="hs-identifier hs-var">res_hty_is_unit</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-690"></span><span>         </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187778"><span class="hs-identifier hs-var">libffi</span></a></span><span>
</span><span id="line-691"></span><span>                  </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'*'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187762"><span class="hs-identifier hs-var">ffi_cResType</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'*'</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span>
</span><span id="line-692"></span><span>                       </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;resp = cret;&quot;</span></span><span>
</span><span id="line-693"></span><span>                  </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;return cret;&quot;</span></span><span>
</span><span id="line-694"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#rbrace"><span class="hs-identifier hs-var">rbrace</span></a></span><span>
</span><span id="line-695"></span><span>     </span><span class="hs-special">]</span><span>
</span><span id="line-696"></span><span>
</span><span id="line-697"></span><span>
</span><span id="line-698"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#foreignExportsInitialiser"><span class="hs-identifier hs-type">foreignExportsInitialiser</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Module"><span class="hs-identifier hs-type">Module</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-699"></span><span id="foreignExportsInitialiser"><span class="annot"><span class="annottext">foreignExportsInitialiser :: Module -&gt; [Id] -&gt; SDoc
</span><a href="GHC.HsToCore.Foreign.Decl.html#foreignExportsInitialiser"><span class="hs-identifier hs-var hs-var">foreignExportsInitialiser</span></a></span></span><span> </span><span id="local-6989586621681187724"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681187724"><span class="hs-identifier hs-var">mod</span></a></span></span><span> </span><span id="local-6989586621681187723"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187723"><span class="hs-identifier hs-var">hs_fns</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-700"></span><span>   </span><span class="hs-comment">-- Initialise foreign exports by registering a stable pointer from an</span><span>
</span><span id="line-701"></span><span>   </span><span class="hs-comment">-- __attribute__((constructor)) function.</span><span>
</span><span id="line-702"></span><span>   </span><span class="hs-comment">-- The alternative is to do this from stginit functions generated in</span><span>
</span><span id="line-703"></span><span>   </span><span class="hs-comment">-- codeGen/CodeGen.hs; however, stginit functions have a negative impact</span><span>
</span><span id="line-704"></span><span>   </span><span class="hs-comment">-- on binary sizes and link times because the static linker will think that</span><span>
</span><span id="line-705"></span><span>   </span><span class="hs-comment">-- all modules that are imported directly or indirectly are actually used by</span><span>
</span><span id="line-706"></span><span>   </span><span class="hs-comment">-- the program.</span><span>
</span><span id="line-707"></span><span>   </span><span class="hs-comment">-- (this is bad for big umbrella modules like Graphics.Rendering.OpenGL)</span><span>
</span><span id="line-708"></span><span>   </span><span class="hs-comment">--</span><span>
</span><span id="line-709"></span><span>   </span><span class="hs-comment">-- See Note [Tracking foreign exports] in rts/ForeignExports.c</span><span>
</span><span id="line-710"></span><span>   </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span>
</span><span id="line-711"></span><span>    </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;static struct ForeignExportsList&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187722"><span class="hs-identifier hs-var">list_symbol</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#equals"><span class="hs-identifier hs-var">equals</span></a></span><span>
</span><span id="line-712"></span><span>         </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-713"></span><span>           </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;.exports = &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187720"><span class="hs-identifier hs-var">export_list</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-714"></span><span>           </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;.n_entries = &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Arity -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; Arity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Arity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187723"><span class="hs-identifier hs-var">hs_fns</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-715"></span><span>         </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#semi"><span class="hs-identifier hs-var">semi</span></a></span><span>
</span><span id="line-716"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;static void &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187719"><span class="hs-identifier hs-var">ctor_symbol</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;(void)&quot;</span></span><span>
</span><span id="line-717"></span><span>         </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; __attribute__((constructor));&quot;</span></span><span>
</span><span id="line-718"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;static void &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187719"><span class="hs-identifier hs-var">ctor_symbol</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;()&quot;</span></span><span>
</span><span id="line-719"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;registerForeignExports&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'&amp;'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187722"><span class="hs-identifier hs-var">list_symbol</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#semi"><span class="hs-identifier hs-var">semi</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-720"></span><span>    </span><span class="hs-special">]</span><span>
</span><span id="line-721"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-722"></span><span>    </span><span id="local-6989586621681187718"><span class="annot"><span class="annottext">mod_str :: SDoc
</span><a href="#local-6989586621681187718"><span class="hs-identifier hs-var hs-var">mod_str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; SDoc
</span><a href="GHC.Unit.Module.Name.html#pprModuleName"><span class="hs-identifier hs-var">pprModuleName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module -&gt; ModuleName
forall unit. GenModule unit -&gt; ModuleName
</span><a href="GHC.Unit.Types.html#moduleName"><span class="hs-identifier hs-var hs-var">moduleName</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681187724"><span class="hs-identifier hs-var">mod</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-723"></span><span>    </span><span id="local-6989586621681187719"><span class="annot"><span class="annottext">ctor_symbol :: SDoc
</span><a href="#local-6989586621681187719"><span class="hs-identifier hs-var hs-var">ctor_symbol</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stginit_export_&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187718"><span class="hs-identifier hs-var">mod_str</span></a></span><span>
</span><span id="line-724"></span><span>    </span><span id="local-6989586621681187722"><span class="annot"><span class="annottext">list_symbol :: SDoc
</span><a href="#local-6989586621681187722"><span class="hs-identifier hs-var hs-var">list_symbol</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stg_exports_&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187718"><span class="hs-identifier hs-var">mod_str</span></a></span><span>
</span><span id="line-725"></span><span>    </span><span id="local-6989586621681187720"><span class="annot"><span class="annottext">export_list :: SDoc
</span><a href="#local-6989586621681187720"><span class="hs-identifier hs-var hs-var">export_list</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; SDoc) -&gt; [Id] -&gt; SDoc
forall a. (a -&gt; SDoc) -&gt; [a] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#pprWithCommas"><span class="hs-identifier hs-var">pprWithCommas</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
</span><a href="#local-6989586621681187714"><span class="hs-identifier hs-var">closure_ptr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681187723"><span class="hs-identifier hs-var">hs_fns</span></a></span><span>
</span><span id="line-726"></span><span>
</span><span id="line-727"></span><span>    </span><span class="annot"><a href="#local-6989586621681187714"><span class="hs-identifier hs-type">closure_ptr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-728"></span><span>    </span><span id="local-6989586621681187714"><span class="annot"><span class="annottext">closure_ptr :: Id -&gt; SDoc
</span><a href="#local-6989586621681187714"><span class="hs-identifier hs-var hs-var">closure_ptr</span></a></span></span><span> </span><span id="local-6989586621681187713"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187713"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;(StgPtr) &amp;&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681187713"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;_closure&quot;</span></span><span>
</span><span id="line-729"></span><span>
</span><span id="line-730"></span><span>
</span><span id="line-731"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#mkHObj"><span class="hs-identifier hs-type">mkHObj</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-732"></span><span id="mkHObj"><span class="annot"><span class="annottext">mkHObj :: Type -&gt; SDoc
</span><a href="GHC.HsToCore.Foreign.Decl.html#mkHObj"><span class="hs-identifier hs-var hs-var">mkHObj</span></a></span></span><span> </span><span id="local-6989586621681187712"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187712"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rts_mk&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; String
</span><a href="GHC.HsToCore.Foreign.Decl.html#showFFIType"><span class="hs-identifier hs-var">showFFIType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187712"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-733"></span><span>
</span><span id="line-734"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#unpackHObj"><span class="hs-identifier hs-type">unpackHObj</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-735"></span><span id="unpackHObj"><span class="annot"><span class="annottext">unpackHObj :: Type -&gt; SDoc
</span><a href="GHC.HsToCore.Foreign.Decl.html#unpackHObj"><span class="hs-identifier hs-var hs-var">unpackHObj</span></a></span></span><span> </span><span id="local-6989586621681187710"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187710"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rts_get&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; String
</span><a href="GHC.HsToCore.Foreign.Decl.html#showFFIType"><span class="hs-identifier hs-var">showFFIType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187710"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-736"></span><span>
</span><span id="line-737"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#showStgType"><span class="hs-identifier hs-type">showStgType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-738"></span><span id="showStgType"><span class="annot"><span class="annottext">showStgType :: Type -&gt; SDoc
</span><a href="GHC.HsToCore.Foreign.Decl.html#showStgType"><span class="hs-identifier hs-var hs-var">showStgType</span></a></span></span><span> </span><span id="local-6989586621681187709"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187709"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Hs&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; String
</span><a href="GHC.HsToCore.Foreign.Decl.html#showFFIType"><span class="hs-identifier hs-var">showFFIType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187709"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-739"></span><span>
</span><span id="line-740"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#showFFIType"><span class="hs-identifier hs-type">showFFIType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-741"></span><span id="showFFIType"><span class="annot"><span class="annottext">showFFIType :: Type -&gt; String
</span><a href="GHC.HsToCore.Foreign.Decl.html#showFFIType"><span class="hs-identifier hs-var hs-var">showFFIType</span></a></span></span><span> </span><span id="local-6989586621681187708"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187708"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; String
forall a. NamedThing a =&gt; a -&gt; String
</span><a href="GHC.Types.Name.html#getOccString"><span class="hs-identifier hs-var">getOccString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Name
forall a. NamedThing a =&gt; a -&gt; Name
</span><a href="GHC.Types.Name.html#getName"><span class="hs-identifier hs-var">getName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; TyCon
</span><a href="GHC.HsToCore.Foreign.Decl.html#typeTyCon"><span class="hs-identifier hs-var">typeTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187708"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-742"></span><span>
</span><span id="line-743"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#toCType"><span class="hs-identifier hs-type">toCType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#Header"><span class="hs-identifier hs-type">Header</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-744"></span><span id="toCType"><span class="annot"><span class="annottext">toCType :: Type -&gt; (Maybe Header, SDoc)
</span><a href="GHC.HsToCore.Foreign.Decl.html#toCType"><span class="hs-identifier hs-var hs-var">toCType</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Type -&gt; (Maybe Header, SDoc)
</span><a href="#local-6989586621681187706"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-745"></span><span>    </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681187706"><span class="annot"><span class="annottext">f :: Bool -&gt; Type -&gt; (Maybe Header, SDoc)
</span><a href="#local-6989586621681187706"><span class="hs-identifier hs-var hs-var">f</span></a></span></span><span> </span><span id="local-6989586621681187693"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187693"><span class="hs-identifier hs-var">voidOK</span></a></span></span><span> </span><span id="local-6989586621681187692"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187692"><span class="hs-identifier hs-var">t</span></a></span></span><span>
</span><span id="line-746"></span><span>           </span><span class="hs-comment">-- First, if we have (Ptr t) of (FunPtr t), then we need to</span><span>
</span><span id="line-747"></span><span>           </span><span class="hs-comment">-- convert t to a C type and put a * after it. If we don't</span><span>
</span><span id="line-748"></span><span>           </span><span class="hs-comment">-- know a type for t, then &quot;void&quot; is fine, though.</span><span>
</span><span id="line-749"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681187691"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187691"><span class="hs-identifier hs-var">ptr</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621681187690"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187690"><span class="hs-identifier hs-var">t'</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187692"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-750"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187691"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; [Name] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Name
</span><a href="GHC.Builtin.Names.html#ptrTyConName"><span class="hs-identifier hs-var">ptrTyConName</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="GHC.Builtin.Names.html#funPtrTyConName"><span class="hs-identifier hs-var">funPtrTyConName</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-751"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Type -&gt; (Maybe Header, SDoc)
</span><a href="#local-6989586621681187706"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187690"><span class="hs-identifier hs-var">t'</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-752"></span><span>                </span><span class="hs-special">(</span><span id="local-6989586621681187685"><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681187685"><span class="hs-identifier hs-var">mh</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187684"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187684"><span class="hs-identifier hs-var">cType'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-753"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681187685"><span class="hs-identifier hs-var">mh</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681187684"><span class="hs-identifier hs-var">cType'</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'*'</span></span><span class="hs-special">)</span><span>
</span><span id="line-754"></span><span>           </span><span class="hs-comment">-- Otherwise, if we have a type constructor application, then</span><span>
</span><span id="line-755"></span><span>           </span><span class="hs-comment">-- see if there is a C type associated with that constructor.</span><span>
</span><span id="line-756"></span><span>           </span><span class="hs-comment">-- Note that we aren't looking through type synonyms or</span><span>
</span><span id="line-757"></span><span>           </span><span class="hs-comment">-- anything, as it may be the synonym that is annotated.</span><span>
</span><span id="line-758"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681187683"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187683"><span class="hs-identifier hs-var">tycon</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe TyCon
</span><a href="GHC.Core.Type.html#tyConAppTyConPicky_maybe"><span class="hs-identifier hs-var">tyConAppTyConPicky_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187692"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-759"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.ForeignCall.html#CType"><span class="hs-identifier hs-type">CType</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681187680"><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681187680"><span class="hs-identifier hs-var">mHeader</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SourceText
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681187679"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187679"><span class="hs-identifier hs-var">cType</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe CType
</span><a href="GHC.Core.TyCon.html#tyConCType_maybe"><span class="hs-identifier hs-var">tyConCType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187683"><span class="hs-identifier hs-var">tycon</span></a></span><span>
</span><span id="line-760"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681187680"><span class="hs-identifier hs-var">mHeader</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CLabelString -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ftext"><span class="hs-identifier hs-var">ftext</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681187679"><span class="hs-identifier hs-var">cType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-761"></span><span>           </span><span class="hs-comment">-- If we don't know a C type for this type, then try looking</span><span>
</span><span id="line-762"></span><span>           </span><span class="hs-comment">-- through one layer of type synonym etc.</span><span>
</span><span id="line-763"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681187677"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187677"><span class="hs-identifier hs-var">t'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe Type
</span><a href="GHC.Core.Type.html#coreView"><span class="hs-identifier hs-var">coreView</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187692"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-764"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Type -&gt; (Maybe Header, SDoc)
</span><a href="#local-6989586621681187706"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187693"><span class="hs-identifier hs-var">voidOK</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187677"><span class="hs-identifier hs-var">t'</span></a></span><span>
</span><span id="line-765"></span><span>           </span><span class="hs-comment">-- This may be an 'UnliftedFFITypes'-style ByteArray# argument</span><span>
</span><span id="line-766"></span><span>           </span><span class="hs-comment">-- (which is marshalled like a Ptr)</span><span>
</span><span id="line-767"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe TyCon
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#byteArrayPrimTyCon"><span class="hs-identifier hs-var">byteArrayPrimTyCon</span></a></span><span>        </span><span class="annot"><span class="annottext">Maybe TyCon -&gt; Maybe TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe TyCon
</span><a href="GHC.Core.Type.html#tyConAppTyConPicky_maybe"><span class="hs-identifier hs-var">tyConAppTyConPicky_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187692"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-768"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Header
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;const void*&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-769"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe TyCon
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#mutableByteArrayPrimTyCon"><span class="hs-identifier hs-var">mutableByteArrayPrimTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TyCon -&gt; Maybe TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe TyCon
</span><a href="GHC.Core.Type.html#tyConAppTyConPicky_maybe"><span class="hs-identifier hs-var">tyConAppTyConPicky_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187692"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-770"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Header
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;void*&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-771"></span><span>           </span><span class="hs-comment">-- Otherwise we don't know the C type. If we are allowing</span><span>
</span><span id="line-772"></span><span>           </span><span class="hs-comment">-- void then return that; otherwise something has gone wrong.</span><span>
</span><span id="line-773"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681187693"><span class="hs-identifier hs-var">voidOK</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Header
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;void&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-774"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-775"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; (Maybe Header, SDoc)
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;toCType&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187692"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-776"></span><span>
</span><span id="line-777"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#typeTyCon"><span class="hs-identifier hs-type">typeTyCon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>
</span><span id="line-778"></span><span id="typeTyCon"><span class="annot"><span class="annottext">typeTyCon :: Type -&gt; TyCon
</span><a href="GHC.HsToCore.Foreign.Decl.html#typeTyCon"><span class="hs-identifier hs-var hs-var">typeTyCon</span></a></span></span><span> </span><span id="local-6989586621681187672"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187672"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-779"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681187671"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187671"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#tcSplitTyConApp_maybe"><span class="hs-identifier hs-var">tcSplitTyConApp_maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="GHC.Types.RepType.html#unwrapType"><span class="hs-identifier hs-var">unwrapType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187672"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-780"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681187671"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-781"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-782"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TyCon
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.HsToCore.Foreign.Decl.typeTyCon&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187672"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-783"></span><span>
</span><span id="line-784"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#insertRetAddr"><span class="hs-identifier hs-type">insertRetAddr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-type">CCallConv</span></a></span><span>
</span><span id="line-785"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Type.html#CmmType"><span class="hs-identifier hs-type">CmmType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-786"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Type.html#CmmType"><span class="hs-identifier hs-type">CmmType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-787"></span><span id="insertRetAddr"><span class="annot"><span class="annottext">insertRetAddr :: Platform
-&gt; CCallConv
-&gt; [(SDoc, SDoc, Type, CmmType)]
-&gt; [(SDoc, SDoc, Type, CmmType)]
</span><a href="GHC.HsToCore.Foreign.Decl.html#insertRetAddr"><span class="hs-identifier hs-var hs-var">insertRetAddr</span></a></span></span><span> </span><span id="local-6989586621681187668"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187668"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-var">CCallConv</span></a></span><span> </span><span id="local-6989586621681187666"><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187666"><span class="hs-identifier hs-var">args</span></a></span></span><span>
</span><span id="line-788"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Arch
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformArch"><span class="hs-identifier hs-var">platformArch</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187668"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-789"></span><span>      </span><span class="annot"><span class="annottext">Arch
</span><a href="../../ghc-boot/src/GHC.Platform.html#ArchX86_64"><span class="hs-identifier hs-var">ArchX86_64</span></a></span><span>
</span><span id="line-790"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformOS"><span class="hs-identifier hs-var">platformOS</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187668"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">OS -&gt; OS -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#OSMinGW32"><span class="hs-identifier hs-var">OSMinGW32</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-791"></span><span>          </span><span class="hs-comment">-- On other Windows x86_64 we insert the return address</span><span>
</span><span id="line-792"></span><span>          </span><span class="hs-comment">-- after the 4th argument, because this is the point</span><span>
</span><span id="line-793"></span><span>          </span><span class="hs-comment">-- at which we need to flush a register argument to the stack</span><span>
</span><span id="line-794"></span><span>          </span><span class="hs-comment">-- (See rts/Adjustor.c for details).</span><span>
</span><span id="line-795"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span class="annot"><a href="#local-6989586621681187661"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Type.html#CmmType"><span class="hs-identifier hs-type">CmmType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-796"></span><span>                        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Type.html#CmmType"><span class="hs-identifier hs-type">CmmType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-797"></span><span>              </span><span id="local-6989586621681187661"><span class="annot"><span class="annottext">go :: Arity
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187661"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">4</span></span><span> </span><span id="local-6989586621681187660"><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187660"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; (SDoc, SDoc, Type, CmmType)
</span><a href="GHC.HsToCore.Foreign.Decl.html#ret_addr_arg"><span class="hs-identifier hs-var">ret_addr_arg</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187668"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc, SDoc, Type, CmmType)
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187660"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-798"></span><span>              </span><span class="annot"><a href="#local-6989586621681187661"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681187658"><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187658"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681187657"><span class="annot"><span class="annottext">(SDoc, SDoc, Type, CmmType)
</span><a href="#local-6989586621681187657"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681187656"><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187656"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SDoc, SDoc, Type, CmmType)
</span><a href="#local-6989586621681187657"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc, SDoc, Type, CmmType)
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">Arity
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187661"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187658"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Arity -&gt; Arity -&gt; Arity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187656"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-799"></span><span>              </span><span class="annot"><a href="#local-6989586621681187661"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-800"></span><span>          </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Arity
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187661"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187666"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-801"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-802"></span><span>          </span><span class="hs-comment">-- On other x86_64 platforms we insert the return address</span><span>
</span><span id="line-803"></span><span>          </span><span class="hs-comment">-- after the 6th integer argument, because this is the point</span><span>
</span><span id="line-804"></span><span>          </span><span class="hs-comment">-- at which we need to flush a register argument to the stack</span><span>
</span><span id="line-805"></span><span>          </span><span class="hs-comment">-- (See rts/Adjustor.c for details).</span><span>
</span><span id="line-806"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span class="annot"><a href="#local-6989586621681187654"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Type.html#CmmType"><span class="hs-identifier hs-type">CmmType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-807"></span><span>                        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Type.html#CmmType"><span class="hs-identifier hs-type">CmmType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-808"></span><span>              </span><span id="local-6989586621681187654"><span class="annot"><span class="annottext">go :: Arity
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187654"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">6</span></span><span> </span><span id="local-6989586621681187653"><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187653"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; (SDoc, SDoc, Type, CmmType)
</span><a href="GHC.HsToCore.Foreign.Decl.html#ret_addr_arg"><span class="hs-identifier hs-var">ret_addr_arg</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187668"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc, SDoc, Type, CmmType)
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187653"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-809"></span><span>              </span><span class="annot"><a href="#local-6989586621681187654"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681187652"><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187652"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681187651"><span class="annot"><span class="annottext">arg :: (SDoc, SDoc, Type, CmmType)
</span><a href="#local-6989586621681187651"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">SDoc
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681187650"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681187650"><span class="hs-identifier hs-var">rep</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681187649"><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187649"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-810"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#cmmEqType_ignoring_ptrhood"><span class="hs-identifier hs-var">cmmEqType_ignoring_ptrhood</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681187650"><span class="hs-identifier hs-var">rep</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="GHC.Cmm.Type.html#b64"><span class="hs-identifier hs-var">b64</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SDoc, SDoc, Type, CmmType)
</span><a href="#local-6989586621681187651"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc, SDoc, Type, CmmType)
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">Arity
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187654"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187652"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Arity -&gt; Arity -&gt; Arity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187649"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-811"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SDoc, SDoc, Type, CmmType)
</span><a href="#local-6989586621681187651"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc, SDoc, Type, CmmType)
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">Arity
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187654"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681187652"><span class="hs-identifier hs-var">n</span></a></span><span>     </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187649"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-812"></span><span>              </span><span class="annot"><a href="#local-6989586621681187654"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-813"></span><span>          </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Arity
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187654"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187666"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-814"></span><span>      </span><span class="annot"><span class="annottext">Arch
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-815"></span><span>          </span><span class="annot"><span class="annottext">Platform -&gt; (SDoc, SDoc, Type, CmmType)
</span><a href="GHC.HsToCore.Foreign.Decl.html#ret_addr_arg"><span class="hs-identifier hs-var">ret_addr_arg</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187668"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc, SDoc, Type, CmmType)
-&gt; [(SDoc, SDoc, Type, CmmType)] -&gt; [(SDoc, SDoc, Type, CmmType)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187666"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-816"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#insertRetAddr"><span class="hs-identifier hs-var">insertRetAddr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681187646"><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187646"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(SDoc, SDoc, Type, CmmType)]
</span><a href="#local-6989586621681187646"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-817"></span><span>
</span><span id="line-818"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#ret_addr_arg"><span class="hs-identifier hs-type">ret_addr_arg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Type.html#CmmType"><span class="hs-identifier hs-type">CmmType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-819"></span><span id="ret_addr_arg"><span class="annot"><span class="annottext">ret_addr_arg :: Platform -&gt; (SDoc, SDoc, Type, CmmType)
</span><a href="GHC.HsToCore.Foreign.Decl.html#ret_addr_arg"><span class="hs-identifier hs-var hs-var">ret_addr_arg</span></a></span></span><span> </span><span id="local-6989586621681187645"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187645"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;original_return_addr&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;void*&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
forall a. HasCallStack =&gt; a
</span><a href="../../base/src/GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-820"></span><span>                         </span><span class="annot"><span class="annottext">Platform -&gt; Type -&gt; CmmType
</span><a href="GHC.Cmm.Utils.html#typeCmmType"><span class="hs-identifier hs-var">typeCmmType</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187645"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#addrPrimTy"><span class="hs-identifier hs-var">addrPrimTy</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-821"></span><span>
</span><span id="line-822"></span><span class="hs-comment">-- This function returns the primitive type associated with the boxed</span><span>
</span><span id="line-823"></span><span class="hs-comment">-- type argument to a foreign export (eg. Int ==&gt; Int#).</span><span>
</span><span id="line-824"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#getPrimTyOf"><span class="hs-identifier hs-type">getPrimTyOf</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.RepType.html#UnaryType"><span class="hs-identifier hs-type">UnaryType</span></a></span><span>
</span><span id="line-825"></span><span id="getPrimTyOf"><span class="annot"><span class="annottext">getPrimTyOf :: Type -&gt; Type
</span><a href="GHC.HsToCore.Foreign.Decl.html#getPrimTyOf"><span class="hs-identifier hs-var hs-var">getPrimTyOf</span></a></span></span><span> </span><span id="local-6989586621681187643"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187643"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-826"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isBoolTy"><span class="hs-identifier hs-var">isBoolTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187641"><span class="hs-identifier hs-var">rep_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#intPrimTy"><span class="hs-identifier hs-var">intPrimTy</span></a></span><span>
</span><span id="line-827"></span><span>  </span><span class="hs-comment">-- Except for Bool, the types we are interested in have a single constructor</span><span>
</span><span id="line-828"></span><span>  </span><span class="hs-comment">-- with a single primitive-typed argument (see TcType.legalFEArgTyCon).</span><span>
</span><span id="line-829"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-830"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (TyCon, [Type], DataCon, [Scaled Type])
</span><a href="GHC.Core.DataCon.html#splitDataProductType_maybe"><span class="hs-identifier hs-var">splitDataProductType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187641"><span class="hs-identifier hs-var">rep_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-831"></span><span>     </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187638"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681187638"><span class="hs-identifier hs-var">data_con</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681187637"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187637"><span class="hs-identifier hs-var">prim_ty</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-832"></span><span>        </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">dataConSourceArity</span><span> </span><span class="hs-identifier">data_con</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-number">1</span><span class="hs-special">)</span><span>
</span><span id="line-833"></span><span>        </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span class="hs-identifier">isUnliftedType</span><span> </span><span class="hs-identifier">prim_ty</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">prim_ty</span><span class="hs-special">)</span><span>
</span><span id="line-834"></span><span>        </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187637"><span class="hs-identifier hs-var">prim_ty</span></a></span><span>
</span><span id="line-835"></span><span>     </span><span id="local-6989586621681187633"><span class="annot"><span class="annottext">Maybe (TyCon, [Type], DataCon, [Scaled Type])
</span><a href="#local-6989586621681187633"><span class="hs-identifier hs-var">_other</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; Type
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.HsToCore.Foreign.Decl.getPrimTyOf&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187643"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-836"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-837"></span><span>        </span><span id="local-6989586621681187641"><span class="annot"><span class="annottext">rep_ty :: Type
</span><a href="#local-6989586621681187641"><span class="hs-identifier hs-var hs-var">rep_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="GHC.Types.RepType.html#unwrapType"><span class="hs-identifier hs-var">unwrapType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187643"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-838"></span><span>
</span><span id="line-839"></span><span class="hs-comment">-- represent a primitive type as a Char, for building a string that</span><span>
</span><span id="line-840"></span><span class="hs-comment">-- described the foreign function type.  The types are size-dependent,</span><span>
</span><span id="line-841"></span><span class="hs-comment">-- e.g. 'W' is a signed 32-bit integer.</span><span>
</span><span id="line-842"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Decl.html#primTyDescChar"><span class="hs-identifier hs-type">primTyDescChar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span>
</span><span id="line-843"></span><span id="primTyDescChar"><span class="annot"><span class="annottext">primTyDescChar :: Platform -&gt; Type -&gt; Char
</span><a href="GHC.HsToCore.Foreign.Decl.html#primTyDescChar"><span class="hs-identifier hs-var hs-var">primTyDescChar</span></a></span></span><span> </span><span id="local-6989586621681187632"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187632"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681187631"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187631"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-844"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187631"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Bool
</span><a href="GHC.Core.Type.html#eqType"><span class="hs-operator hs-var">`eqType`</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#unitTy"><span class="hs-identifier hs-var">unitTy</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'v'</span></span><span>
</span><span id="line-845"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-846"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; PrimRep
Type -&gt; PrimRep
</span><a href="GHC.Types.RepType.html#typePrimRep1"><span class="hs-identifier hs-var">typePrimRep1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="GHC.HsToCore.Foreign.Decl.html#getPrimTyOf"><span class="hs-identifier hs-var">getPrimTyOf</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187631"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-847"></span><span>     </span><span class="annot"><span class="annottext">PrimRep
</span><a href="GHC.Core.TyCon.html#IntRep"><span class="hs-identifier hs-var">IntRep</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621681187628"><span class="hs-identifier hs-var">signed_word</span></a></span><span>
</span><span id="line-848"></span><span>     </span><span class="annot"><span class="annottext">PrimRep
</span><a href="GHC.Core.TyCon.html#WordRep"><span class="hs-identifier hs-var">WordRep</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621681187626"><span class="hs-identifier hs-var">unsigned_word</span></a></span><span>
</span><span id="line-849"></span><span>     </span><span class="annot"><span class="annottext">PrimRep
</span><a href="GHC.Core.TyCon.html#Int64Rep"><span class="hs-identifier hs-var">Int64Rep</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'L'</span></span><span>
</span><span id="line-850"></span><span>     </span><span class="annot"><span class="annottext">PrimRep
</span><a href="GHC.Core.TyCon.html#Word64Rep"><span class="hs-identifier hs-var">Word64Rep</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'l'</span></span><span>
</span><span id="line-851"></span><span>     </span><span class="annot"><span class="annottext">PrimRep
</span><a href="GHC.Core.TyCon.html#AddrRep"><span class="hs-identifier hs-var">AddrRep</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'p'</span></span><span>
</span><span id="line-852"></span><span>     </span><span class="annot"><span class="annottext">PrimRep
</span><a href="GHC.Core.TyCon.html#FloatRep"><span class="hs-identifier hs-var">FloatRep</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'f'</span></span><span>
</span><span id="line-853"></span><span>     </span><span class="annot"><span class="annottext">PrimRep
</span><a href="GHC.Core.TyCon.html#DoubleRep"><span class="hs-identifier hs-var">DoubleRep</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'d'</span></span><span>
</span><span id="line-854"></span><span>     </span><span class="annot"><span class="annottext">PrimRep
</span><span class="hs-identifier">_</span></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; Char
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;primTyDescChar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681187631"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-855"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-856"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681187628"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621681187628"><span class="hs-identifier hs-var">signed_word</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681187626"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621681187626"><span class="hs-identifier hs-var">unsigned_word</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; PlatformWordSize
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformWordSize"><span class="hs-identifier hs-var hs-var">platformWordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681187632"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-857"></span><span>      </span><span class="annot"><span class="annottext">PlatformWordSize
</span><a href="../../ghc-boot/src/GHC.Platform.html#PW4"><span class="hs-identifier hs-var">PW4</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'W'</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'w'</span></span><span class="hs-special">)</span><span>
</span><span id="line-858"></span><span>      </span><span class="annot"><span class="annottext">PlatformWordSize
</span><a href="../../ghc-boot/src/GHC.Platform.html#PW8"><span class="hs-identifier hs-var">PW8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'L'</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'l'</span></span><span class="hs-special">)</span><span>
</span><span id="line-859"></span></pre></body></html>